Sending a mail with records from a Table

How can we send a mail through X++ ? My requirement is I want to send the mail picking the records from the table. i.e I want to display the records of a table in the mail (which should be sent through code)

Can anyone pls help me on this ?

This Job can help you brother. 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(@" Blue Company Customers");
htmlTable.Append(@"
“);
htmlTable.Append(”");

while select custTable where custtable.CustGroup == ‘AP’
{
htmlTable.Append("

");
htmlTable.Append("");
htmlTable.Append("");
htmlTable.Append("");
}

htmlTable.Append("

");
htmlTable.Append(custTable.AccountNum);
htmlTable.Append("
");
htmlTable.Append(custTable.NameAlias);
htmlTable.Append("
");

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();

Thanks for ur code Sayeed.

Actually I am using an E-mail template ,so my requirement is to use that template where I will have some static text and a parameter.

For that parameter I need to pass table records (these records should be displayed in the mail in tabular form) through the code and send the mail.

Can u pls suggest me on this?

Hi,

If you have a standard DAX 2009 demo VPC, you can see a similar functionality working. This functionality combines setting up Email templates and alerts.