Here i building a html table string of all customers belonging to a customer group and sending it through smtp server. The mail client interprets the html of the message and display the customers in a table of records.
You can build the html table by merging with the records of your table and send the mail.
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(“<TABLE BORDER=1>”);
while select custTable where custtable.CustGroup == ‘AP’
{
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(“Axapta@bluecompany.com”);
mailer.tos().appendAddress(“sayeed@bluecompany.com”);
// Setting SMTP details
mailer.SMTPRelayServer(“192.168.4.67″,87,”AXMail”,”1234″,false);
// Sending Mail
mailer.sendMail();
No comments:
Post a Comment