Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Email settings for Office 365 / Outlook


  • Please log in to reply
13 replies to this topic
flyingDman
  • Spam Officer
  • 2186 posts
  • Last active: Nov 07 2015 08:15 AM
  • Joined: 27 Feb 2009

I wonder if anyone has successfully used the code below for Outlook / Office 365.  This works for me for Gmail and GMX but for Outlook it does not go through and gives me a "Transport failed to connect to the server" error message. SMTP  and port are those as provided by their website.

 

pmsg 				:= ComObjCreate("CDO.Message")
pmsg.From 			:= """John Doe"" <[email protected]>"
pmsg.To 			:= "[email protected]"
pmsg.BCC 			:= ""   				; Blind Carbon Copy, Invisible for all, same syntax as CC
pmsg.CC 			:= "[email protected]"			; [email protected], [email protected]
pmsg.Subject 			:= "See attached"
pmsg.HtmlBody 			:= "<html><head><title></title></head><body><H1>Hello John</H1></body></html>"

;sAttach   			:= "" 					; can add multiple attachments, the delimiter is |

fields 				:= Object()
fields.smtpserver   		:= "pod51011.outlook.com"	        ; as provided by MS Outlook WebApp
fields.smtpserverport   	:= 587 					; as provided by MS Outlook WebApp
fields.smtpusessl      		:= True 				; False ?
fields.sendusing     		:= 2   					; cdoSendUsingPort ?
fields.smtpauthenticate 	:= 1   					; cdoBasic ?
fields.sendusername 		:= "[email protected]"
fields.sendpassword 		:= "xxx"
fields.smtpconnectiontimeout    := 60
schema 				:= "http://schemas.microsoft.com/cdo/configuration/"
pfld 				:=  pmsg.Configuration.Fields

For field,value in fields
	pfld.Item(schema . field) := value
pfld.Update()

Loop, Parse, sAttach, |, %A_Space%%A_Tab%
  pmsg.AddAttachment(A_LoopField)
pmsg.Send()

Marine Corps Gen. Joseph Dunford told senators at his Joint Chiefs of Staff confirmation hearing : “If you want to talk about a nation that could pose an existential threat to the United States, I'd have to point to Russia. And if you look at their behavior, it's nothing short of alarming.”


Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

Does this work with Outlook Express (OE), too?



flyingDman
  • Spam Officer
  • 2186 posts
  • Last active: Nov 07 2015 08:15 AM
  • Joined: 27 Feb 2009

Note that this is a way to send emails bypassing your current email-application. So it does not use OE, Outlook, or any email client. What I am looking for is the settings needed to use it with various providers.  It works just fine for Gmail and GMX but can't get it to work with the email service provided by MS in Office 365 WebApp called Outlook.   This is part of Sharepoint an enterprise platform.


Marine Corps Gen. Joseph Dunford told senators at his Joint Chiefs of Staff confirmation hearing : “If you want to talk about a nation that could pose an existential threat to the United States, I'd have to point to Russia. And if you look at their behavior, it's nothing short of alarming.”


Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

Can you send to Yahoo (or att.yahoo) like you can send to Gmail?



Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

This script appears to run without any error messages but the mail never arrives! icon_cry.gif

; this file is built from an example in the ahk forums and made into a function for including
; http://www.autohotke...-to-send-email/

SMTPServer=smtp.att.yahoo.com

SMTPPort=465

Sender=***

Receiver=***

Subject="***"

TextBody="***"

Attachments="***"

SendUserName=***

SendPassword=***

;USESSL

;Attachments=C:\...\***.txt

; using #include c:\pathtofile\sendmail.ahk

SendMail(SMTPServer, SMTPPort, USESSL, Sender, Receiver, Subject, TextBody, Attachments="", SendUserName="username", SendPassword="password", SendUsing=2, SMTPAuthenticate=1, SMTPTimeout=60, ReplyTo=FALSE)
{
pmsg := ComObjCreate("CDO.Message")
pmsg.From := Sender
pmsg.ReplyTo := Sender
pmsg.To := Receiver
pmsg.BCC := ""
pmsg.CC := ""
pmsg.Subject := Subject
pmsg.TextBody := TextBody
sAttach := Attachments

fields := Object()
fields.smtpserver := SMTPServer ; specify your SMTP server
fields.smtpserverport := SMTPPort ; 25
fields.smtpusessl := USESSL ; False
fields.sendusing := SendUsing ; cdoSendUsingPort
fields.smtpauthenticate := SMTPAuthenticate ; cdoBasic
fields.sendusername := SendUserName ; if required
fields.sendpassword := SendPassword ; if required
fields.smtpconnectiontimeout := SMTPTimeout
/*
schema := "http://schemas.microsoft.com/cdo/configuration/"

pfld := pmsg.Configuration.Fields
For field,value in fields
pfld.Item(schema . field) := Value
pfld.Update()

; add attachments
Loop, Parse, sAttach, |, %A_Space%%A_Tab%
pmsg.AddAttachment(A_LoopField)
*/
; send the msg
pmsg.Send()
return
}


flyingDman
  • Spam Officer
  • 2186 posts
  • Last active: Nov 07 2015 08:15 AM
  • Joined: 27 Feb 2009

Sendmail.ahk and the code I quoted are essentially the same. Don't think you can leave the part starting with schema out and I believe you have to assign a value to USESSL (0 or 1 depending on your provider).


Marine Corps Gen. Joseph Dunford told senators at his Joint Chiefs of Staff confirmation hearing : “If you want to talk about a nation that could pose an existential threat to the United States, I'd have to point to Russia. And if you look at their behavior, it's nothing short of alarming.”


Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

Where can I get the schema for att.yahoo.com?



flyingDman
  • Spam Officer
  • 2186 posts
  • Last active: Nov 07 2015 08:15 AM
  • Joined: 27 Feb 2009

This seems to be universal. Just uncomment it.


Marine Corps Gen. Joseph Dunford told senators at his Joint Chiefs of Staff confirmation hearing : “If you want to talk about a nation that could pose an existential threat to the United States, I'd have to point to Russia. And if you look at their behavior, it's nothing short of alarming.”


Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

On http://forums.x10.com/ I found this for att.yahoo.com among others:

I'm new to the Forum but I thought I'd weigh-in on the "won't send E-mail from MyHouse, OnAlert,...." I've been running Smart Macros, OnAlert, and My house on-line for a couple of weeks now and of course I couldn't send E-mails from AHP. That is, from my primary E-mail account on SBCGlobal.net. However, I soon found out that E-mails worked from my secondary account at SprintPCS.com. So what was the difference? SBCGlobal.net requires authentication and SSL on port 465 and SprintPCS just uses port 25 with no authentication or SSL.

After reviewing posts on the Forum and searching the net for CreateObject("CDO.Message"), I came up with a script that works for my primary account.

Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM

Set objMessage = CreateObject("CDO.Message")
objMessage.From = "[email protected]"
objMessage.To = "[email protected]"
objMessage.Subject = "ALERT - WINDOW SENSOR ALARMED"
objMessage.TextBody = "This is some sample message text..." & vbCRLF & "It was sent using SMTP authentication."

'==This section provides the configuration information for the remote SMTP server.
objMessage.Configuration.Fields.Item _
("http://schemas.micro...ation/sendusing") = cdoSendUsingPort

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.micro...tion/smtpserver") = "SMTP.ATT.YAHOO.com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.micro...mtpauthenticate") = 1

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.micro.../smtpserverport") = 465

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.micro...tion/smtpusessl") = TRUE
objMessage.Configuration.Fields.Item _
("http://schemas.micro...on/sendusername") = "[email protected]"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.micro...on/sendpassword") = "yourpassword"

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.micro...nnectiontimeout") = 30

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send

Set objMessage = Nothing

The above script works on ameritech.net, att.net, prodigy, sbcglobal, etc. - any account that used smtp.att.yahoo.com for outgoing SMTP.

I too, think this method is more robust than the AHP methods. Appears to be faster also.



flyingDman
  • Spam Officer
  • 2186 posts
  • Last active: Nov 07 2015 08:15 AM
  • Joined: 27 Feb 2009

So does your script work with Usessl =1 and the uncommented shema lines? (what did you learn form that X10.com post? I fail to see).


Marine Corps Gen. Joseph Dunford told senators at his Joint Chiefs of Staff confirmation hearing : “If you want to talk about a nation that could pose an existential threat to the United States, I'd have to point to Russia. And if you look at their behavior, it's nothing short of alarming.”


Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

No much! I still can't get it working... icon_cry.gif



Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

While picking some random pages using http://www.autohotke...om-page-picker/

URL := "http://www.autohotkey.com/board/forum/49-scripts/"
UrlDownloadToFile, %URL%, AHK.html ; DOWNLOAD HTML
FileRead, HTML, AHK.html ; READ HTML TO VARIABLE
FileDelete, AHK.html ; DELETE HTML FILE
URL := StrX( HTML, "<link rel='last' href='",1,23, "' />",1,4 ) ; GET URL OF 'LAST PAGE'
PAGES := StrX( URL, "page-",1,5, "?prune",1,1 ) ; GET PAGE NUMBER FROM 'LAST PAGE' URL
Random, RANDOM_PAGE, 1, %PAGES%
;MsgBox, % RANDOM_PAGE
URL := "http://www.autohotkey.com/board/forum/49-scripts/page-?prune_day=100&sort_by=Z-A&sort_key=last_post&topicfilter=all"
StringReplace, URL, URL, page-, page-%RANDOM_PAGE%
Run, %URL%
StrX(H,BS="",BO=0,BT=1,ES="",EO=0,ET=1,ByRef N="") { ; BY SKAN | 19-NOV-2009
Return SubStr(H,P:=(((Z:=StrLen(ES))+(X:=StrLen(H))+StrLen(BS)-Z-X)?((T:=InStr(H,BS,0,((BO
<0)?(1):(BO))))?(T+BT):(X+1)):(1)),(N:=P+((Z)?((T:=InStr(H,ES,0,((EO)?(P+1):(0))))?(T-P+Z
+(0-ET)):(X+P)):(X)))-P) ; V1.0-196C 21-NOV-2009 WWW.AUTOHOTKEY.COM/FORUM/TOPIC51354.HTML

I came across http://www.autohotke...delivery-ahk-l/ randomly.

 

Using this script, I was able to send mail SUCCESSFULLY. icon_razz.gif



flyingDman
  • Spam Officer
  • 2186 posts
  • Last active: Nov 07 2015 08:15 AM
  • Joined: 27 Feb 2009

@Guest10: I do not know where you're going with this. The script you point out in your last post  (http://www.autohotke...delivery-ahk-l/) is the exact same that I started with,... which did not seem to work for you.  


Marine Corps Gen. Joseph Dunford told senators at his Joint Chiefs of Staff confirmation hearing : “If you want to talk about a nation that could pose an existential threat to the United States, I'd have to point to Russia. And if you look at their behavior, it's nothing short of alarming.”


Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

Any ideas how I can get text message attachments "inline"? That is to get the attachment text to show in the body of the message?