Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

Hi. Does anyone see a problem with the code below? When I execute that code against sqla 12, I see normal execution times, but no email is received. Thanks.

call xp_startmail();
call xp_sendmail("recipient" = '', "subject" = 'MAPI / SMTP - Test Mail', "message" = 'This is a test mail. Please do not reply.');
call xp_stopmail();

asked 09 Apr '14, 18:39

dejstone's gravatar image

accept rate: 0%

(09 Apr '14, 18:45) Volker Barth

Do you actually have an email server ready to accept the email you are sending?

Is it MAPI or SMTP? (your use of xp_startmail implies "MAPI")

Are you using Microsoft Exchange?

You probably need to specify a user name.

Plus, what Volker said... check the return codes using the Super Funky Form of CALL...

DECLARE @return_code                   INTEGER;

      @return_code = CALL xp_startmail (
         mail_user     = @mapi_mail_username,
         mail_password = @mapi_mail_password );

      IF @return_code <> 0 THEN
         ...something bad happened

And when none of that works, switch to SMTP and use Google's server :)...

permanent link

answered 09 Apr '14, 21:18

Breck%20Carter's gravatar image

Breck Carter
accept rate: 20%

edited 10 Apr '14, 08:51

Breck, we are having better luck with SMTP, however, our app must offer both SMTP and MAPI. Based on your example, I tried this code from ISQL...

BEGIN DECLARE @return_code INTEGER; @return_code = CALL xp_startmail(mail_user = ''); MESSAGE @return_code TO CLIENT ; END

... which generated an Error 5. A few years ago, when we first placed the MAPI/SMTP capability into the app, all was fine. However, that may have been before our email was connected to Microsoft Exchange. Any thoughts/suggestions?

(11 Apr '14, 10:26) dejstone
Replies hidden

AFAIK, several years ago Micosoft introduced a feature to disallow programs to send mail via MAPI automatically (i.e. without explicit user confirmation). May that apply here?

(11 Apr '14, 11:17) Volker Barth

Are you sure any of your clients can use MAPI to send emails from within ANY executable program?

Are you sure any of your clients CARE?

FYI Microsoft doesn't want you to use xp_startmail or ANY of the related xp-email-thingies in SQL Server. See xp_startmail (Transact-SQL): "This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature."

If you still want to proceed with MAPI, please start a new question specifically related to the error code returned by xp_startmail().

(11 Apr '14, 11:58) Breck Carter

Are you sure any of your clients CARE?<<
You may be right. Though, I was working with a customer just last week who uses our MAPI email, they use Groupwise email and I think their MAPI is activated from the workstation, not the DB Server.

(13 Apr '14, 13:49) dejstone
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 09 Apr '14, 18:39

question was seen: 2,356 times

last updated: 13 Apr '14, 13:52