Question:

You create an application to send a message by e-mail. An SMTP server is available on the local subnet. The SMTP server is named smtp.contoso.com.

To test the application, you use a source address, me@contoso.com, and a target address, you@contoso. com.

You need to transmit the e-mail message.

Which code segment should you use?

 

A MailAddress addrFrom =
new MailAddress("me@contoso.com", "Me");
MailAddress addrTo =
new MailAddress("you@contoso.com", "You");
MailMessage message = new MailMessage(addrFrom, addrTo); message.Subject = "Greetings!"; message.Body = "Test";
SocketInformation info = new SocketInformation();
Socket client = new Socket(info);
System.Text.ASCIIEncoding enc =
new System.Text.ASCIIEncoding();
byte[] msgBytes = enc.GetBytes(message.ToString());
client.Send(msgBytes); 

B MailAddress addrFrom = new MailAddress("me@contoso.com"); MailAddress addrTo = new MailAddress("you@contoso.com"); MailMessage message = new MailMessage(addrFrom, addrTo); message.Subject = "Greetings!";
message.Body = "Test";
SmtpClient client = new SmtpClient("smtp.contoso.com"); client.Send(message); 

C string strSmtpClient = "smtp.contoso.com";
string strFrom = "me@contoso.com";
string strTo = "you@contoso.com";
string strSubject = "Greetings!";
string strBody = "Test";
MailMessage msg =
new MailMessage(strFrom, strTo, strSubject, strSmtpClient); 

D MailAddress addrFrom =
new MailAddress("me@contoso.com", "Me");
MailAddress addrTo =
new MailAddress("you@contoso.com", "You");
MailMessage message = new MailMessage(addrFrom, addrTo); message.Subject = "Greetings!";
message.Body = "Test";
message.Dispose(); 

+ Answer
+ Report
Total Preview: 697

Copyright © 2024. Powered by Intellect Software Ltd