Link to home
Start Free TrialLog in
Avatar of XGenwareS
XGenwareS

asked on

VB.Net Hotmail/Windows Live

I have a VB.Net Application that needs to be able to send emails using a Hotmail/Windows Live Account. From what i have researched, I found that I need to use these settings:
     
 Hotmail Incoming Mail Server (POP3) - pop3.live.com (logon using Secure Password Authentification - SPA, mail server port: 995)

 Hotmail Outgoing Mail Server (SMTP) - smtp.live.com (SSL enabled, port 25)

Now how would I be able to use that to send a simple, text only email from vb.net?
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

You do not say if it's a web application or windows, but I will assume web.
'code to send email

Private Sub SendInquiryByEmail()
        Try
            Dim mm As New System.Net.Mail.MailMessage(System.Configuration.ConfigurationManager.AppSettings("sender"), System.Configuration.ConfigurationManager.AppSettings("primeRecipient"))
            If Not System.Configuration.ConfigurationManager.AppSettings("ccRecipient") Is Nothing Then
                mm.CC.Add(System.Configuration.ConfigurationManager.AppSettings("ccRecipient"))
            End If
            If Not System.Configuration.ConfigurationManager.AppSettings("ccRecipient") Is Nothing Then
                mm.Bcc.Add(System.Configuration.ConfigurationManager.AppSettings("bccRecipient"))
            End If
            mm.Subject = "Subject here"
            mm.Body = "Message body here."
            mm.IsBodyHtml = False  'Plain text message
            Dim smtp As New SmtpClient
            smtp.Send(mm)
        Catch ex As Exception
            Me.errorMsg.Value = ex.ToString()
        End Try
    End Sub

'web.config settings

<system.net>
		<mailSettings>
			<smtp>
				<network
					 host="smtp.live.com"
					 port="25"
					 userName="username"
					 password="password" />
			</smtp>
		</mailSettings>
	</system.net>

<appSettings>
		<add key="primeRecipient" value="prime@recipient.com"/>
		<add key="ccRecipient" value="copyTo@recipient.com"/>
		<add key="bccRecipient" value="blindCopyTo@recipient.com"/>
		<add key="sender" value="me@sender.com"/>
	</appSettings>

Open in new window

Avatar of XGenwareS
XGenwareS

ASKER

Sorry for that specifying. Its a windows app.
ASKER CERTIFIED SOLUTION
Avatar of Tom Beck
Tom Beck
Flag of United States of America 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
Thanks works great!