Best way to send an email from a .NET application?

后端 未结 6 1912
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-06 07:16

I\'m working on a Windows Forms (.NET 3.5) application that has a built-in exception handler to catch any (heaven forbid) exceptions that may arise. I\'d like the exception

6条回答
  •  [愿得一人]
    2020-12-06 07:54

    You shouldn't need to worry about client credentials and just use the SmtpClient as suggested by Esteban. You will need the user to provide a valid Smtp server url at configuration, but most ISPs allow anonymous smtp providing you are on their network (one of their clients) - as long as the user puts in the url for their ISPs smptp server then most people wouldn't have any problems.

    Note: There is a predefined section of the .config file for storing the configuration options for the SmtpClient object. If you put the settings in there you don't have to explicitly set anything in you code when sending an email. An example of the section is below:

    
       
          
             
          
       
    
    

    The user name and password are optional. Intellisense works for these parts of the config file.

    Edit: slight correction to my code example.

提交回复
热议问题