Sends the MAIL command.
null or an empty String.
The MAIL command begins a mail transaction, and tells the SMTP server the sender of the current message.
Various SMTP extensions permit optional parameters to the MAIL command. One of the most useful extensions is the SIZE extension defined in RFC 1870. The SIZE extension allows the client to report the size of a message to the server before it sends the message. The server may then reject a message that is too large. (The alternative is for the server to reject the message after the message is sent!)
The MailFrom method takes the sender email address as
a required parameter, and a list of MAIL command parameters as an
optional parameter. The sender string should be
a simple email address in the form "jdoe@example.org". The
parameters string should contain the MAIL
command parameters as they would be sent in the MAIL command line.
parameters may be null or an empty
string.
String sender = "jdoe@example.org";
String parms = String.Format("SIZE={0}", messageSize);
smtpClient.MailFrom(sender, parms);
After the method returns, you should check the server's reply code, available as the ReplyCode property. A 250 reply code indicates success.
Note: The "sender" is considered part of the SMTP envelope, and may be different from the "From" header field of the actual message. The SMTP envelope sender is associated with message delivery, indicating a return address ("return path") for delivery status notifications.
| Exception Type | Condition |
|---|---|
| Exception | If a network or protocol error occurs. |
SmtpClient Class | Hunny.Mail Namespace | MAIL command in the SMTP specification