on 2024 Aug 19 4:26 PM
I'm having trouble getting the following xp_sendsmtp documentation example working: 'This example uses SMTP to send inline HTML formatted message with a signature and two attachments, one of which is a ZIP file.'
The slightly modified example, with obvious placeholders, is shown below.
Suggestions or insights welcome. Thank you!
begin
declare l_rc integer;
declare s_content long varchar;
--
SET s_content =
'Content-Type: multipart/mixed; boundary="xxxxx";\\n' ||
'This part of the email should not be shown. If this ' ||
'is shown then the email client is not MIME compatible\\n\\n' ||
'--xxxxx\\n' ||
'Content-Type: text/html;\\n' ||
'Content-Disposition: inline;\\n\\n' ||
'Plain text.' ||
/* xp_read_file( '\\\\temp\\\\johndoe.sig.html' ) || */
'--xxxxx\\n' ||
'Content-Type: application/zip; name="test.zip"\\n' ||
'Content-Transfer-Encoding: base64\\n' ||
'Content-Disposition: attachment; filename="test.zip"\\n\\n' ||
base64_encode( xp_read_file( 'c:\\\\temp\\\\test.zip' ) ) ||
'\\n\\n' ||
'--xxxxx--\\n'
;
--
-- Port 2525 is for non-ssl email
l_rc = call xp_startsmtp (
smtp_sender = '(sender email)',
smtp_server = '(mail server)',
smtp_port = 2525,
smtp_sender_name = 'John Doe',
smtp_auth_username = '(sender email)',
smtp_auth_password = '(password)'
);
--
l_rc = call xp_sendmail (
recipient = 'joe@contoso.com',
subject = 'Test sending email with attachment from SQL Anywhere',
"message" = s_content,
content_type = 'ASIS',
include_file = '\\\\temp\\\\bla.sql'
);
--
l_rc = call xp_stopsmtp ();
end
go
Request clarification before answering.
We have had all sorts of issues with include_file in recent years, particularly when the emails are received / handled by Exchange/Outlook, the problem being content isn't shown.
These days we now don't use include_file and attached everything "manually" using repeated part sections in the email content build up
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks. Per my comment above, "content isn't shown" is consistent with what we are running into. "include_file" works fine for us if the "content" value string is just text, including HTML.
It would be great if you could post some examples of "manually using repeated part sections in the email content build up". We're not expert on this. We want the email message to be HTML content to display in a body, plus an attachment file, ideally without having to create the file and then use "include_file" to attach it.
This is a subset of a procedure that emails various documents which are held in variables (Doc1, Doc2, Doc3) with inline image in the signature.
I'm not saying it is perfect but it works 😉
Hope this helps (my forum foo formatting isn't very good)
set "vBody" = 'Content-Type: multipart/mixed; boundary="xxxxx";\ ' || 'This part of the email should not be shown. If this ' || 'is shown then the email client is not MIME compatible\ \ ' || '--xxxxx\ ' || 'Content-Type: text/html;\ ' || 'Content-Disposition: inline;\ \ ' || '`<html>\ <head></head>\ <body>Docs received
These docs have been received.
\ ' || 'Doc1: ' || "Doc1" || '.
'` || "xp_read_file"('D:\\\\system-email-sig.htm') || '--xxxxx\ ' || 'Content-Type: application/png; name="image001.png"\ ' || 'Content-Transfer-Encoding: base64\ ' || 'Content-Disposition: attachment; filename="image001.png"\ \ ' || "base64_encode"("xp_read_file"('D:\\\\image001.png')) || '\ \ '; if "Doc1" is not null then set "vBody" = "vBody" || '--xxxxx\ ' || 'Content-Type: application/pdf; name="Doc1.pdf"\ ' || 'Content-Transfer-Encoding: base64\ ' || 'Content-Disposition: attachment; filename="Doc1.pdf"\ \ ' || "base64_encode"("Doc1") || '\ \ ' end if; if "Doc2" is not null then set "vBody" = "vBody" || '--xxxxx\ ' || 'Content-Type: application/pdf; name="Doc2.pdf"\ ' || 'Content-Transfer-Encoding: base64\ ' || 'Content-Disposition: attachment; filename="Doc2.pdf"\ \ ' || "base64_encode"("Doc2") || '\ \ ' end if; if "Doc3" is not null then set "vBody" = "vBody" || '--xxxxx\ ' || 'Content-Type: application/pdf; name="Doc3.pdf"\ ' || 'Content-Transfer-Encoding: base64\ ' || 'Content-Disposition: attachment; filename="Doc3.pdf"\ \ ' || "base64_encode"("Doc3") || '\ \ ' end if; set "vBody" = "vBody" || '--xxxxx--\ '; call "xp_startsmtp"('noreply@domain.comm','mail.domain.com'); call "xp_sendmail"("recipient" = 'ops@domain.com',"subject" = 'Duplicate PreAlert processed',"message" = "vBody","content_type" = 'ASIS'); call "xp_stopsmtp"();
User | Count |
---|---|
74 | |
30 | |
9 | |
7 | |
7 | |
6 | |
6 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.