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
RuttensoftAsked:
Who is Participating?
 
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:
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:
so how'd you go?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.