System.Web.SmtpMail becomes System.Net.Mail.SmtpClient

// set smtp server

SmtpMail.SmtpServer = System.Configuration.ConfigurationManager.AppSettings["SMTPServer"].ToString();

// send mail
SmtpMail.Send(from, to, subject, body);

Now becomes:

SmtpClient mail = new SmtpClient();
mail.Host = System.Configuration.
ConfigurationManager.AppSettings["SMTPServer"]
mail.Send(from, to, subject, body);

# re: System.Web.SmtpMail becomes System.Net.Mail.SmtpClient

Saturday, April 16, 2005 2:26 PM by John Wood    
Good that makes far more sense... it almost seemed like the framework designers for that area thought SMTP was a "web thing".. quite strange. In fact I didn't even discover it until like a year after I started using .Net because I never thought of looking in that namespace for it!

# re: System.Web.SmtpMail becomes System.Net.Mail.SmtpClient

Saturday, April 16, 2005 11:05 PM by Maher K. Al-Jendasi    
Also there are several email related classes have been deprecated:

1- System.Web.Mail.SmtpMail
2- System.Web.Mail.MailFormat (enum)
3- System.Web.Mail.MailEncoding
4- System.Web.Mail.MailAttachment
5- System.Web.Mail.MailMessage

It's now adviced to use the classes in System.Net.Mail instead of them, for example, use System.Net.Mail.MailMessage instead of System.Web.Mail.MailMessage


# Problem with System.net.mail in asp.net 2 beta 2

Thursday, April 21, 2005 11:39 AM by Asaf Blasberg    
Hello, i get "The specified string is not in the form required for an e-mail address" for the code below:

(i already have the system.net namespace on the top of my aspx page so I don't have to put in systme.net.mail... all the time)

Dim msg As Mail.MailMessage = New Mail.MailMessage
Dim address As Mail.MailAddress = New Mail.MailAddress("asaf@nyc.rr.com")
msg.To.Add(address)
msg.IsBodyHtml = True
msg.Body = "test"
msg.Subject = "test"
Dim smtp As Mail.SmtpClient = New Mail.SmtpClient
smtp.Send(msg)

# re: System.Web.SmtpMail becomes System.Net.Mail.SmtpClient

Tuesday, May 17, 2005 1:18 AM by Ernst Kuschke    
ConfigurationManager.AppSettings has changed in BETA2:
<a target="_new" href="http://dotnet.org.za/ernst/archive/2005/05/11/19792.aspx">http://dotnet.org.za/ernst/archive/2005/05/11/19792.aspx</a>

# re: System.Web.SmtpMail becomes System.Net.Mail.SmtpClient

Monday, April 02, 2007 2:07 PM by hol    
ddddd

# re: System.Web.SmtpMail becomes System.Net.Mail.SmtpClient

Tuesday, November 11, 2008 7:29 AM by sad    
asdfasd

Post a Comment

 
 
Prove you're not a spammer: 
5 + 5 =