Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I am trying to send mail from aspx page but it gives Error
<b>"MailMessage is ambiguous,imported from the namespaces or types System.Net.Mail"
</b>. A code that I am using for send email is as below.so pls help me

Imports System.Net.Mail

Dim message As New MailMessage
SmtpMail.SmtpServer = "smtp.mail.yahoo.com"
message.[To] = "dhl_gandhi@yahoo.com"
message.From = "sender@domainName.com"
message.Subject = "Email Subject"
message.BodyFormat = MailFormat.Html
message.body = "Test Message"
SmtpMail.Send(message)
Response.Write("Email Sent")


Thanks
Posted

You've probaly got MailMessage defined somewhere in scope.

try :
Dim message As New System.Net.Mail.MailMessage
 
Share this answer
 
There must be two namespaces where MailMessage exists.Check it.

Have a look on thread
 
Share this answer
 
Check this article



Regards,
Jamil
 
Share this answer
 
you can use System.Web.Mail

Imports System.Web.Mail

Dim message As New MailMessage
SmtpMail.SmtpServer = "smtp.mail.yahoo.com"
message.[To] = "dhl_gandhi@yahoo.com"
message.From = "sender@domainName.com"
message.Subject = "Email Subject"
message.BodyFormat = MailFormat.Html
message.body = "Test Message"
SmtpMail.Send(message)
Response.Write("Email Sent")
 
Share this answer
 
I had try System.web.mail but it gives error
<b>"The server rejected the sender address. The server response was: 530 5.7.0 Must issue a STARTTLS command first. b17sm3564929wam.10"</b>
So whats the problem
 
Share this answer
 
Your server requires authentication. If you have an existing mail client connected to this server, try to look at the parameters of the connection to the smtp server, and try reproducing them in your mail client.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900