Friday, April 8, 2011

Sending email via Axapta

I've managed to get my Axapta 3.0 to send email via the printjobSettings class. However, there doesn't appear to be anywhere I can create a body for my email. Currently I can send email with an attachment but I'd like to include some text to provide some context for the attachment for the recipient.

How can I accomplish this?

From stackoverflow
  • The class printJobSettings has a method mailSubject for setting the subject of the email that gets generated, but there is no method for setting the body of the message. printJobSettings is a kernel class, so you can't modify it.

    To actually send the email, the kernel passes a printJobSettings object to the method Info.ReportSendMail, which you can modify. So as a work around, pack your subject and body together in the subject, then unpack them in ReportSendMail.

    In your report:

    printJobSettings.mailSubject(msgSubject + '|' + msgBody);
    

    In Info.ReportSendMail:

    subjectAndBody=printJobSettings.mailSubject();
    delimiterPos=strFind(subjectAndBody,'|',1,strlen(subjectAndBody));
    if(delimiterPos>0)
    {
        msgSubject=subStr(subjectAndBody,1,delimiterPos-1);
        msgBody=subStr(subjectAndBody,delimiterPos+1,strlen(subjectAndBody)-delimiterPos);
    }
    else
    {
        msgSubject=subjectAndBody;
        msgBody='Axapta Report';
    }
    
  • Jay, thanks very much for your reply .. most appreciated!

0 comments:

Post a Comment