Solved

Send mail using authenticate mode in VB2010

Posted on 2011-09-29
2
296 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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 …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

740 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