I need to create a simple email code in code. This is necessary because the information in the letter will be read by the application.
I created the following value in a constant line as a setting for my letter. These are the fields that I want to be in the email, because the application requires them.
public static string TestMail = @"
[Begin Message]
Name = {0}
Phone = {1}
Postalcode = {2}
HomeNumber = {3}
[End message]";
When sending email using the code below, the application that should read the information from the email receives it as follows:
=0D=0A [Begin Message]=0D=0A Name =3D nam=
e=0D=0A Phone =3D 0612345678=0D=0A Postalcode =3D =
1234ab=0D=0A HomeNumber =3D 5=0D=0A [End messa=
ge]=0D=0A =20
The code I used to send this message is as follows:
var mailBody = String.Format(Constants.TestMail, name, phone, postalCode, homeNumber);
var mail = new MailMessage
{
Subject = Constants.Subject,
Body = mailBody,
IsBodyHtml = false,
};
mail.To.Add(receveiver);
var smtpClient = new SmtpClient();
smtpClient.Send(mail);
, , , , , , - HTML- , , . , VB.net . :
public static string TestMail = @"[Begin message]\r\nName = {0}\r\nPhone = {1}\r\nPostalcode = {2}\r\nHomenumber = {3}\r\n[End message]";
( Outlook)
var mail = new MailMessage
{
Subject = Constants.Subject,
};
var alternateView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(mailBody, Encoding.ASCII,"text/plain");
mail.AlternateViews.Add(alternateView);
mail.To.Add(receveiver);
var smtpClient = new SmtpClient();
smtpClient.Send(mail);
( ), ;
[Start message]\r\nName = John\r\nPhone = 0612345678\r\nPostalcode = 1234ab\r\nHomeNumber = 5\r\n[End Message]
. Outlook 2007 ? - ? , - , .