Solved

VB.Net Hotmail/Windows Live

Posted on 2010-08-25
4
1,134 Views
Last Modified: 2013-11-27
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?
0
Comment
Question by:XGenwareS
  • 2
  • 2
4 Comments
 
LVL 38

Expert Comment

by:Tom Beck
ID: 33527120
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

0
 

Author Comment

by:XGenwareS
ID: 33527124
Sorry for that specifying. Its a windows app.
0
 
LVL 38

Accepted Solution

by:
Tom Beck earned 500 total points
ID: 33527197
Very similar.
Private Sub SendByEmail()
        Try
            Dim mm As New System.Net.Mail.MailMessage("sender@anywhere.com", "recipient@anywhere.com")
            mm.Subject = "Subject here"
            mm.Body = "Message body here."
            mm.IsBodyHtml = False
            Dim smtp As New System.Net.Mail.SmtpClient("smtp.live.com", 25)
            smtp.Send(mm)
        Catch ex As Exception
            Console.Write(ex.ToString())
        End Try
    End Sub

Open in new window

0
 

Author Comment

by:XGenwareS
ID: 33527217
Thanks works great!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now