Quantcast
Channel: AX Developer Forum
Viewing all articles
Browse latest Browse all 9880

Unable to send attachment in sending mail in Ax 2009 !

$
0
0

Hi

I am able to send mail if i run the job but if i add attachment code it goes to visual studio debugger some win32 exception and AX closes.

Is it possible to add attachment in AX 2009 ?

static void TestMail(Args _args)

{

CustTable custTable;

    System.Text.StringBuilder htmlTable;

    SysMailer mailer;

    str   filePathName;

    ;

 

  // filePathName = @'C:\Test.txt';

  // mailer.attachments().add(filePathName);

 

   htmlTable = new System.Text.StringBuilder();

   htmlTable.Append(@"<caption>Company Customers");

   htmlTable.Append(@"  </caption> </br>");

   htmlTable.Append("<TABLE BORDER=1>");

 

   while select custTable where custtable.CustGroup == 'FLAT1'

   {

      htmlTable.Append("<TR ALIGN='CENTER'>");

      htmlTable.Append("<TD>");

      htmlTable.Append(custTable.AccountNum);

      htmlTable.Append("</TD>");

      htmlTable.Append("<TD>");

      htmlTable.Append(custTable.NameAlias);

      htmlTable.Append("</TD>");

      htmlTable.Append("</TR>");

   }

   htmlTable.Append("</TABLE>");

   mailer = new SysMailer();

    //building mail details

    mailer.htmlBody(htmlTable.ToString());

    mailer.subject("Automated Mail - Customers");

    mailer.fromAddress("AAA@abc.com");

    mailer.tos().appendAddress(" BBB@abc.com");

    // Setting SMTP details

    mailer.SMTPRelayServer("10.11.12.123",25,"myname","mypassword",false);

    // Sending Mail

    mailer.sendMail();

}


Viewing all articles
Browse latest Browse all 9880

Trending Articles