Hunny Software Library Reference

SmtpClient.RcptTo Method 

Sends the RCPT command.

[Visual Basic]
Public Sub RcptTo( _
   ByVal recipient As String, _
   ByVal parameters As String _
)
[C#]
public void RcptTo(
   string recipient,
   string parameters
);

Parameters

recipient
The recipient argument of the RCPT command.
parameters
The optional command parameters of the RCPT command. The value may be null or an empty String.

Remarks

The RCPT command follows the MAIL command, and tells the SMTP server one of the recipients of the current message. The RCPT command may be repeated multiple times to tell the SMTP server of multiple recipients.

The RcptTo method takes the recipient email address as a required parameter, and a list of RCPT command parameters as an optional parameter. The recipient string should be a simple email address in the form "jdoe@example.org". The parameters string should contain the RCPT command parameters as they would be sent in the RCPT command line. parameters may be null or an empty string.

            String recipient = "jdoe@example.org";
            smtpClient.RcptTo(recipient, null);
            

After the method returns, you should check the server's reply code, available as the ReplyCode property. A 250 or 251 reply code indicates success.

Note: The "recipient" is considered part of the SMTP envelope, and may be different from the "To" or "Cc" header fields of the actual message. The SMTP envelope recipient is associated with message delivery, indicating an address ("forward path") for final mail delivery.

Exceptions

Exception TypeCondition
ExceptionIf a network or protocol error occurs.

See Also

SmtpClient Class | Hunny.Mail Namespace | RCPT command in the SMTP specification