SoFunction
Updated on 2025-03-06

C# Example of sending emails using netmail


/// <summary>
/// The NetMail method passed
    /// </summary>
    private void TestSend()
    {
        mm = new ();
//Recipient address
        (new ("xxxxxx@", "Name"));
//Sender address
        = new ("xxxxx@");
//This can be not specified
        // = new ("xxx@", "SenderName");、

        = "This is Test Email";
        = "<h3>This is Testing SMTP Mail Send By Me</h3>";
        = true;
= ; // Set the priority of sending emails
        smtCliend = new ();
//Specify the mail server
        = "";
//Port number of smtp mail server
        = 25;  
//Set the user name and address of the sender's email address. It is generally necessary to provide it using a public mail server, otherwise the sending will not be successful.
        = new NetworkCredential("xxxxxxx", "xxxxxxx");

//Specify the sending method of email
        = ;
        try
        {
            (mm);
        }
        catch ( ex)
        {
            ();
        }
        catch (Exception ex)
        {
            ();
        }
    }