Solved

Send mail using authenticate mode in VB2010

Posted on 2011-09-29
2
290 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
2 Comments
 
LVL 32

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 69

Assisted Solution

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

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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 …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now