If I run same code without batch processing (as a job), it runs fine.
Somehow when I run it through batch processing (RunBaseBatch class) I am
getting below error:
"Method 'send' in COM object of class 'CDO.Message' returned error code
0x8004020E (<unknown>) which means: <unknown>."
Here is my code to send an email:
static void sendEmail(str _emailTo,str _subject,str _bodyText)
{
SysMailer mailer = new SysMailer();
SysEmailParameters parameters = SysEmailParameters::find();
str emailFrom = sysuserInfo::find(curUserId(),false).Email;
;
if (_emailTo != "")
{
if (parameters.SMTPRelayServerName)
{
mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
else
{
mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
mailer.fromAddress(emailFrom);
mailer.tos().appendAddress(_emailTo);
mailer.subject(_subject);
mailer.htmlBody(_bodyText);
mailer.sendMail();
}
}
Any idea?
Thank you in advance.
Ragin
Please also take a look at:
http://axaptafreak.blogspot.com/2006/12/sending-emails-via-smtp-on-aos-server.html
The same problem was discussed there. Hope this helps you solving your
problem.
If not please take a look at this blogpost:
http://sumit-theaxfactor.spaces.live.com/blog/cns!596957786228C73F!208.entry
This article demonstrates some other techniques to send emails with dynamics
ax.
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Thanks
Sudhir
I was just wondering do we need to install any kind of SMTP services on AOS
server? Because when I changed my class to run from client (added 'client'
word in class declaration), I am not getting any error. Basically it suppose
to be run from server.
Ragin
What do you exactly mean by adding smtp server on AX server and what rights
are required to run this feature.
I have tried running the code exclusively from client but am getting this
error.
For me it is not running both on client and server.
Regards,
SKL