Solved

Send mail using authenticate mode in VB2010

Posted on 2011-09-29
2
297 Views
Last Modified: 2012-06-21
Dear experts:

I need to send messages under vb2010 using authenticate mode, I'm trying to do this:

Dim m As New MailMessage
....
m.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1")
m.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username")
m.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password")
...
but I receive "Fields is not a member of System.net.mail.mailmessage" error.
I'm using vb2010, then, using Framework 4.

Any idea to solve this or to send email with authentication under vb2010?
0
Comment
Question by:BemboX
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 34

Accepted Solution

by:
it_saige earned 300 total points
ID: 36818538
Thats because it is not a member of System.Net.Mail.Mailmessage.  It is a member of System.Web.Mail.Mailmessage and is obsolete in .NET 4.0.

http://msdn.microsoft.com/en-us/library/system.web.mail.mailmessage.aspx

You really want something like this:
Dim Message As MailMessage = New MailMessage()
Dim Smtp As New SmtpClient()

Dim SmtpUser As New System.Net.NetworkCredential()
'-- Build Message
Message.From = New MailAddress("someUsername@myemailserver.com", "Some Username")
Message.To.Add(New MailAddress("someRecipient@theirDomain.com", "Some Recipient"))
Message.IsBodyHtml = False

Message.Subject = "Sending mail is fun."
Message.Body = "Mail sent from application"
'-- Define Authenticated User
SmtpUser.UserName = "someUsername"
SmtpUser.Password = "somePassword"
SmtpUser.Domain = "mail.myemailserver.com"

'-- Send Message
Smtp.UseDefaultCredentials = False
Smtp.Credentials = SmtpUser
Smtp.Host = "mail.mailemailserver.com"
Smtp.DeliveryMethod = SmtpDeliveryMethod.Network
Smtp.Send(Message)

Open in new window

HTH,

-saige-
0
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 200 total points
ID: 36818754
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question