Send email via MSN email account

MSN SMTP server requires SSL connection on port 25.

Sample code below uses CDO 2000 class for sending emails

This is sample code. Add error handling and adjust to your requirements as necessary.

* Replace addresses with real ones before running the code
loMail = NEWOBJECT("Cdo2000", "Cdo2000.fxp")
WITH loMail
	.cServer = ""
	.nServerPort = 25	
	.lUseSSL = .T.
	.nAuthenticate = 1 	&& cdoBasic
 	.cUserName = ""
	.cPassword = "yourPassword"
	*.cFrom = ""
	.cFrom = .cUserName
	.cTo = ","
	.cSubject = "CDO 2000 email through MSN SMTP server"
	* Uncomment next lines to send HTML body
	*.cHtmlBody = "<html><body><b>This is an HTML body<br>" + ;
	*		"It'll be displayed by most email clients</b></body></html>" 	
	.cTextBody = "This is a text body." + CHR(13) + CHR(10) + ;
			"It'll be displayed if HTML body is not present or by text only email clients"
	* Attachments are optional
	* .cAttachment = "myreport.pdf, myspreadsheet.xls"
IF loMail.Send() > 0
	FOR i=1 TO loMail.GetErrorCount()
		? i, loMail.Geterror(i)
	* Clear errors
	? "Email sent."

$SEEALSO$ Send email via Gmail account



i get the above error trying to send via (port 587).

The same config details (server, username, password, port etc) work through outlook2007 when i select TSL rather than SSL.

I can't find a cdo option to use TSL....


(Port 25 doesn't work either)



Hi Nigel,

The CDO 2000 supports SSL only.
I run my code again and get the same error as you with port 587. I removed port 587 from the article.
It works fine with port 25, though. Maybe port 25 is blocked by a firewall or your ISP?


i get a 80040217 error "the server response was not available" with port 25.

I connect to other mail servers ok using port 25 so am pretty sure it's not firewall or ISP.

btw is it possible to send RTF in the message body?

Hi Nigel,

CDO 2000 directly supports plain text and HTML body types. For anything else you'll have to explore IBodyPart Interface.

@Sergey, your code (cdo2000) is not working with hotmail now. But, working with gmail. Is there any new upgradation required ?

Add new comment

Filtered HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.