• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 178
  • Last Modified:

Send Email with SMTP-authentification?

Hello

I found a very simple way to send email using system.web.mail.
My Problem is that I want to be able to use smtp-authentification for sending emails...

Can anyone provide a sample for that?

Thanks

Sven
0
Ruttensoft
Asked:
Ruttensoft
  • 4
1 Solution
 
coopzzCommented:
here ya go.
'--------------
Imports System.Web.mail
'--------------
        Dim email As New MailMessage

        With email
            'The email address of the sender
            .From = From

            'The email address of the recipient.
            'Seperate multiple email adresses with a comma seperator
            .To = SendTo

            'The subject of the email
            .Subject = Subject

            'The Priority attached and displayed for the email
            .Priority = Priority

            'The format of the contents of the email
            'MailFormat.Html : Html Content
            'MailFormat.Text : Text Message
            .BodyFormat = MailFormat.Html

            'The contents of the email can be a HTML Formatted Message
            .Body = "<html><body>" & Message & "</body></html>"

            'The name of the smtp server to use for sending emails
            'SmtpMail.SmtpServer is commonly ignored in many applications
            SmtpMail.SmtpServer = "127.0.0.1" 'localhost

            oMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
            oMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "SMTPUserName") 'set your username here
            oMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "SMTPPassword") 'set your password here

       end with

       SmtpMail.Send(oMail)
'---------------------
0
 
coopzzCommented:
sorry screwed the last line.. should be.

SmtpMail.Send(email)
0
 
coopzzCommented:
oh crap great day for me... here it is again.

'--------------
Imports System.Web.mail
'--------------
        Dim oMail As New MailMessage

        With oMail
            'The email address of the sender
            .From = "here@locatAddress.com"

            'The email address of the recipient.
            'Seperate multiple email adresses with a comma seperator
            .To = "SomeEmail@Hotmail.com"

            'The subject of the email
            .Subject = "The Subject"

            'The format of the contents of the email
            'MailFormat.Html : Html Content
            'MailFormat.Text : Text Message
            .BodyFormat = MailFormat.Html

            'The contents of the email can be a HTML Formatted Message
            .Body = "<html><body>" & Message & "</body></html>"

            'The name of the smtp server to use for sending emails
            SmtpMail.SmtpServer = "127.0.0.1" 'localhost

            oMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
            oMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "SMTPUserName") 'set your username here
            oMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "SMTPPassword") 'set your password here

       end with

       SmtpMail.Send(oMail)
0
 
coopzzCommented:
so how'd you go?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now