rkreuzer Absent Member.
Absent Member.
2533 views

Is it possible to send mails with attachments by SMTP functions set?

Jump to solution

Hello,

I have the requirement to send mails with attachments to a SMTP mail server.

The attachments are jpg or png files.

Is this possible with the SMTP functions set?

I found the function "WebSmtpSendData", but it seems as if only text files could be sent. 

How can I send attachments?

Thanks for any hint.

Robert.

 

0 Likes
2 Solutions

Accepted Solutions
Highlighted
ckim9 Absent Member.
Absent Member.

RE: Is it possible to send mails with attachments by SMTP functions set?

Jump to solution

You should be able to encode using WebBase64Encode function. Here's a detail on Base64 encoding:

en.wikipedia.org/.../Base64

View solution in original post

0 Likes
Danny Davey Absent Member.
Absent Member.

RE: Is it possible to send mails with attachments by SMTP functions set?

Jump to solution

There is a community article which provides good information on this:

community.microfocus.com/.../15919.how-can-i-attach-a-powerpoint-file-to-an-email-when-testing-smtp.aspx

The article links to another article showing how to do this with a text file.  As the file you are using is not just text, you will need to follow the information to encode the binary data.  It would be something like:

   FOpen(hFile, "c:\\temp\\Image.jpg", OPT_FILE_ACCESS_READWRITE, OPT_FILE_OPEN);

   FSizeGet(hFile, nSize);

   write("file size = "); write(nSize); writeln;

   write("File has been opened"); writeln;

   FRead(hFile, sData, STRING_COMPLETE, nRead);    

   writeln("size of file:= "+string(nRead));

   BinSetLen(sData, nSize);

   writedata (bin(sdata));

You will then need to change the Content-Type within the WebSmtpSendData function in order to send an image file rather than text.

View solution in original post

0 Likes
4 Replies
ckim9 Absent Member.
Absent Member.

RE: Is it possible to send mails with attachments by SMTP functions set?

Jump to solution

I believe you will have to send it as an MIME attachment. You will first need to convert it to MIME-encoded binaries in ASCII 128 format.

0 Likes
Highlighted
ckim9 Absent Member.
Absent Member.

RE: Is it possible to send mails with attachments by SMTP functions set?

Jump to solution

You should be able to encode using WebBase64Encode function. Here's a detail on Base64 encoding:

en.wikipedia.org/.../Base64

View solution in original post

0 Likes
Danny Davey Absent Member.
Absent Member.

RE: Is it possible to send mails with attachments by SMTP functions set?

Jump to solution

There is a community article which provides good information on this:

community.microfocus.com/.../15919.how-can-i-attach-a-powerpoint-file-to-an-email-when-testing-smtp.aspx

The article links to another article showing how to do this with a text file.  As the file you are using is not just text, you will need to follow the information to encode the binary data.  It would be something like:

   FOpen(hFile, "c:\\temp\\Image.jpg", OPT_FILE_ACCESS_READWRITE, OPT_FILE_OPEN);

   FSizeGet(hFile, nSize);

   write("file size = "); write(nSize); writeln;

   write("File has been opened"); writeln;

   FRead(hFile, sData, STRING_COMPLETE, nRead);    

   writeln("size of file:= "+string(nRead));

   BinSetLen(sData, nSize);

   writedata (bin(sdata));

You will then need to change the Content-Type within the WebSmtpSendData function in order to send an image file rather than text.

View solution in original post

0 Likes
rkreuzer Absent Member.
Absent Member.

RE: Is it possible to send mails with attachments by SMTP functions set?

Jump to solution

Hello Danny,

many thanks for the hints and articles.

I'm able now to send emails with any attachment.

Regards

Robert.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.