Link to home
Start Free TrialLog in
Avatar of Ruttensoft
Ruttensoft

asked on

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
Avatar of CooPzZ
CooPzZ
Flag of Australia image

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)
'---------------------
sorry screwed the last line.. should be.

SmtpMail.Send(email)
ASKER CERTIFIED SOLUTION
Avatar of CooPzZ
CooPzZ
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
so how'd you go?