erva 2 Posted November 11, 2022 Hi, Added these properties to TIdmessage: mailMessage.ContentType := 'text/plain'; mailMessage.CharSet := 'UTF-8'; After that mail attachments shows in receivers mail as Base64 format in mail, no attached file is in mail like this: "This is a multi-part message in MIME format --sgPuwCmxSaiDhkWsCT2JPGRD=_YJcryGeg Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline T=C3=A4ss=C3=A4 on =C3=A4=C3=A4kk=C3=B6si=C3=A4 ja liite --sgPuwCmxSaiDhkWsCT2JPGRD=_YJcryGeg Content-Type: application/pdf; name="1.pdf" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="1.pdf" JVBERi0xLjcNCiXi48/TDQoyIDAgb2JqDQo8PC9MZW5ndGggMjcxMi9GaWx0ZXIvRmxhdGVEZWNv ZGU+Pg0Kc3RyZWFtDQp4Aa2aS4/sOhWF5yXVf8gvMH7mISGke+6D8YEjMUDMLiAhQDp3wt/nWzt2 utLd5Up3apB2ynHSy2uvvb39+H69fL1evre/OWSXyjJMi3dTHIeQJ5d9pHRhSsNvf79e/nK9/Pd6 +fLtevndL35Y3DKW4ds/rpe//m3ww6/Xi6fww2//vF7yPLsy8q3sljx849nvvU/F+zJzRe/zl7Us gXvVUfpEm5HfmWee8sc/DN/+db38zD/8eoN0vU8TcIdp8m6e8xDC4nwpn0ObZjcXPlVc8A1sAGwA kJW6B1AAWEg9UGEpbpzTkCExljyUxZU4fw5VjMkFfSq7PG2w4Cf8CBZBowzwGPIhSDCVQ3gKpCm7 MW6QMJ+YkfkE7TGkajo4ktDikt3s0z2SArZ1S5nvKK3abkmYvyGK2EliS4v3EZISghO6CNKE0HSp TfyZ51x6bm31HFvrd/yJZ/pNe72r7+lbutKEULlGvqv3kv4HV6TO/gdGUpsxvmOYvbP86Y+4jZvK........." If mail is not including attachment, it shows as it should in receivers email app. I need to chance some other properties also from TIdSMTP and/or TIdMessage but i don't have any idea what to change. Share this post Link to post
erva 2 Posted November 11, 2022 Also these properties are in TIdmessage: object mailMessage: TIdMessage AttachmentEncoding = 'UUE' Encoding = meDefault Share this post Link to post
Remy Lebeau 1436 Posted November 11, 2022 (edited) 11 hours ago, erva said: Added these properties to TIdmessage: mailMessage.ContentType := 'text/plain'; mailMessage.CharSet := 'UTF-8'; Those are the wrong settings to use when attachments are involved. You should read the following articles on Indy's blog (just ignore the portions about HTML): https://www.indyproject.org/2005/08/17/html-messages/ https://www.indyproject.org/2008/01/16/new-html-message-builder-class/ In your situation, you need to set the top-level ContentType to 'multipart/mixed' instead, and then add the plain text as a TIdText object in the TIdMessage.MessageParts collection, and the PDF as a TIdAttachmentFile object in the TIdMessage.MessageParts collection, for example: IdMessage1.ContentType := 'multipart/mixed'; with TIdText.Create(IdMessage1.MessageParts, nil) do begin ContentType := 'text/plain'; CharSet := 'utf-8'; Body.Text := 'Tässä on ääkkösiä ja liite'; end; with TIdAttachmentFile.Create(IdMessage1.MessageParts, '<path to>\1.pdf') do begin ContentType := 'application/pdf'; end; The helper TIdMessageBuilderPlain class can set that up correctly for you, for example: Builder := TIdMessageBuilderPlain.Create; try Builder.PlainText.Text := 'Tässä on ääkkösiä ja liite'; Builder.PlainTextCharSet := 'utf-8'; Builder.Attachments.Add('<path to>\1.pdf').ContentType := 'application/pdf'; Builder.FillMessage(IdMessage1); finally Builder.Free; end; Quote After that mail attachments shows in receivers mail as Base64 format in mail, no attached file is in mail By setting the top-level ContentType to 'text/plain', you are telling email readers to interpret the email's entire content as just one big plain text document, rather than letting them parse the content for attachments, etc. 10 hours ago, erva said: Also these properties are in TIdmessage: object mailMessage: TIdMessage AttachmentEncoding = 'UUE' Encoding = meDefault The default AttachmentEncoding is 'MIME', you should leave it at that. UUE was popular way back in the days of Usenet groups, but nobody uses those anymore. MIME is the dominant encoding used nowadays. Edited November 11, 2022 by Remy Lebeau Share this post Link to post