Archived Forum Post

Index of archived forum posts

Question:

send email with base64 encoded attachment

Jun 01 '17 at 03:15

Hi,

i have to send encrypted and signed edifact mails with an base64 encoded attachment. Encryption and signing is working fine.

Now someone wrote me, that the attachment is not base64 encoded.

I use the chilkat.dll with powershell and add 1 attachment to every mail with: "$contentType = $email.AddFileAttachment($pathname)"

Is there a way to add the attachment as an base64 part ?

Regards Frank


Answer

The content-encoding of any attachment will automatically be base64, unless the content-type is a "text/..." content-type, in which case it will be quoted-printable.

The AddFileAttachment method will automatically choose the content-type based on the file extension of $pathname (i.e. the filename passed to AddFileAttachment). Thus, if the $contentType returned begins with "text/", then the attachment body will use the quoted-printable encoding (instead of base64).

You can instead call AddFileAttachment2($pathName, $contentType) where you can explicitly set the content-type. For example, pass a $contentType of "application/edifact". This will cause the attachment to be base64 encoded.


Answer

Hi,

thanks for your answer. Then it must be an mistake from the receiver of our edifact mails.

Regards Frank