Popular Posts

Monday 22 August 2011

Sending Mail Through X++

static void Email(Args _args)
{
    CustTable                   custTable;
    System.Text.StringBuilder   htmlTable;
    SysMailer                   mailer;
    ;

    htmlTable   = new System.Text.StringBuilder();
    htmlTable.Append(@"<Caption>Blue Company Customers");
    htmlTable.Append(@"</Caption></br>");
    htmlTable.Append("<TableBorder = 1>");
   
    while select custTable where custTable.CustGroup == '10'
    {
        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();
    mailer.htmlBody(htmlTable.ToString());
    mailer.subject("Automated Mail - Customers");
    mailer.fromAddress("kishorem@b2bsoftech.local");
    mailer.tos().appendAddress("chakradhar@b2bsoftech.local");
    mailer.SMTPRelayServer("192.168.4.67",87,"AXMail","1234",false);
    mailer.sendMail();
}

No comments:

Post a Comment