send Email in asp.net 2.0

asp.net Pakistan
  • 12 years ago

    Hi,

    When sending emails to an external address, you must provide authentication credentials to the mail server, otherwise they will not be sent.

    So the account you are impersonating the emails from is the accout you will provide the credentials for and the emails should go.

    I have some example code of what i use to send external emails if you need it.

    Si

  • 12 years ago

    Hi,

    This is what i use.

    imports system.net.mail

    Dim objMail As MailMessage = New MailMessage

    Dim objMailClient As SmtpClient = New SmtpClient

    objMail.From = New Net.Mail.MailAddress(SendFrom) ' SendFrom should be the full email address of the account you are sending from e.g. [email protected]

    For Each strAddress In SendTo.Split(";") ' SendTo should be a string of email addresses separated by a ;

    objMail.To.Add(New MailAddress(strAddress))

    Next

    objMail.Subject = "Subject Line"

    objMail.Body = "The Body of the Email"

    objMailClient.Host = ServerIP ' the ip address of node name of the email server

    objMailClient.Credentials =
    New Net.NetworkCredential(UserName, Password) ' username should be the usre account e.g. test and the password for that account

    objMailClient.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network

    objMailClient.Send(objMail)

    HTH

    Si

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook