MailMessage setting the Senders Name

后端 未结 3 998
心在旅途
心在旅途 2020-12-05 22:56

Is it possible to set the sender name on a MailMessage object? I tried setting it from MailAddress, but the DisplayName property seems

相关标签:
3条回答
  • 2020-12-05 23:24

    From the MSDN http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.aspx

    MailMessage message = new MailMessage(
               "jane@contoso.com",
               "ben@contoso.com",
               "Quarterly data report.",
               "See the attached spreadsheet.");
    
    0 讨论(0)
  • 2020-12-05 23:40

    You do not need to use the MailAddress class.

    You can let the runtime parse your string.

    var message = new MailMessage(
        "My Name my@name.com", 
        "Recipient One recipient@one.com,Recipient Two recipient@two.com",
        "Subject",
        "Body");
    
    0 讨论(0)
  • 2020-12-05 23:46
    MailMessage mail = new MailMessage();
    mail.From = new MailAddress("nerfDeathKnights@mycompany.com", "Bob Jones" );
    
    0 讨论(0)
提交回复
热议问题