AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

COM/WSH/Power Shell + AHK: Send Mail with Outlook

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
BoBo³
Guest





PostPosted: Sat Feb 14, 2009 11:26 pm    Post subject: COM/WSH/Power Shell + AHK: Send Mail with Outlook Reply with quote

What I didn't found at any thread here at the forum:
That article seems to give the answer. Well, to get that up and running - using AHK - would be a live saver (but keep in mind that the issues which are described at the bottom of the articles page needs to be solved too (hopefully)).

Any help is appreciated. Don't hesitate to enlighten us. Thx. Cool
Back to top
BoBo³
Guest





PostPosted: Sat Feb 14, 2009 11:30 pm    Post subject: Reply with quote

Quote:
would be a live saver
Laughing ok, ok, a life saver... ! Wink
Back to top
tank



Joined: 21 Dec 2007
Posts: 3700
Location: Louisville KY USA

PostPosted: Sun Feb 15, 2009 4:24 pm    Post subject: Reply with quote

BoBo
I am not sure if this actually helps you because the prompts are still there
the latest version of COM are required and yes it has been updated recently

Code:
COM_CoInitialize()
oMail:=COM_CreateObject("Outlook.Application")
newMail:=COM_Invoke(oMail,"CreateItem",0)
COM_Invoke(newMail,"Recipients.Add","xyz@xyz.com")
COM_Invoke(newMail,"Subject","test")
COM_Invoke(newMail,"Body","test Mail")
COM_Invoke(newMail,"Send")
COM_CoUninitialize()

_________________

We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 3700
Location: Louisville KY USA

PostPosted: Sun Feb 15, 2009 4:48 pm    Post subject: Reply with quote

with attatchments
I wont help with the security prompts tho
Code:
COM_CoInitialize()
oMail:=COM_CreateObject("Outlook.Application")
newMail:=COM_Invoke(oMail,"CreateItem",0)
COM_Invoke(newMail,"Recipients.Add","xyz@xyz.com")
COM_Invoke(newMail,"Subject","test")
COM_Invoke(newMail,"Body","test Mail")
COM_Invoke(newMail,"Attachments.add", "Path\Filename")
COM_Invoke(newMail,"Send")
COM_CoUninitialize()

_________________

We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Back to top
View user's profile Send private message
BoBo³
Guest





PostPosted: Sun Feb 15, 2009 6:04 pm    Post subject: Reply with quote

Sounds great! Thx tank! Very Happy
will check it out tomorrow (at the office).

Btw, any idea how multiple recipients have to be specified? My assumption:
Code:
COM_Invoke(newMail,"Recipients.Add","xyz@xyz.com;abc@xyz.com;123@xyz.com")
Feel free to confirm. Smile
Back to top
tank



Joined: 21 Dec 2007
Posts: 3700
Location: Louisville KY USA

PostPosted: Sun Feb 15, 2009 6:11 pm    Post subject: Reply with quote

Edit the above doesnt work use this method instead
Code:
COM_Invoke(newMail,"Recipients.Add","xyz1@xyz.com")
COM_Invoke(newMail,"Recipients.Add","xyz2@xyz.com")
COM_Invoke(newMail,"Recipients.Add","xyz3@xyz.com")

_________________

We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Back to top
View user's profile Send private message
BoBo³
Guest





PostPosted: Mon Feb 16, 2009 11:59 am    Post subject: Reply with quote

Great!! Works like a charm. Very Happy

So let's come back to the annoying factor: Outlook security! Shocked - which of course makes sense - but not if me, myself and I wants to send a mail to myself! Confused OK. But that seems to make it: [When the Outlook security warning is fired] Very Happy

If you tank, or anyone out there is able to implement the given/linked workarround into a script (or whatever method), I'll rename my favourite AHK-Hotkey after you (or my next son/daughter)! Very Happy

If you hesitate to provide such kind of "bypassing" features in the forum, don't hesitate to send me (BoBo²) a PM.
Thx 4 Ur time Cool
Back to top
tank



Joined: 21 Dec 2007
Posts: 3700
Location: Louisville KY USA

PostPosted: Mon Feb 16, 2009 3:47 pm    Post subject: Reply with quote

out of sick curiosity
is there any reason not to use sean cdo email
http://www.autohotkey.com/forum/viewtopic.php?t=39797&highlight=cdo+email
_________________

We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Back to top
View user's profile Send private message
BoBo³
Guest





PostPosted: Mon Feb 16, 2009 4:59 pm    Post subject: Reply with quote

I've to use my existing/personalized internal (company) mail account to sent whatever (notification) mails to internal recipients (AND, best case, an external account if I'm on "24/7-OnCall"). SMTP configuration (and other things were I would have to fight with an MS-Exchange administrator) have a 99,98% chance to be denied ad-hoc.

I'd be happy to use Sean's option, if I would be able to collect the neccessary "mandatory settings"-info eg. from my outlook client on my own ... Sad
Back to top
BoBo³
Guest





PostPosted: Mon Feb 16, 2009 5:59 pm    Post subject: Reply with quote

GOSH! Thx, tank (and of course Sean!) IT WORKED!

* Very Happy dancing BoBos Very Happy (looking for the bottle of Aberlour a'bunadh to celebrate that scripting event) *
Back to top
The Unknown Jobber



Joined: 19 Nov 2009
Posts: 161
Location: Florida

PostPosted: Thu Feb 04, 2010 8:49 pm    Post subject: Reply with quote

BoBo³ wrote:
GOSH! Thx, tank (and of course Sean!) IT WORKED!

* Very Happy dancing BoBos Very Happy (looking for the bottle of Aberlour a'bunadh to celebrate that scripting event) *


is it an exchange server?
Back to top
View user's profile Send private message Visit poster's website
OceanMachine



Joined: 15 Oct 2007
Posts: 780
Location: England

PostPosted: Thu Feb 04, 2010 9:01 pm    Post subject: Reply with quote

frescalus wrote:
BoBo³ wrote:
GOSH! Thx, tank (and of course Sean!) IT WORKED!

* Very Happy dancing BoBos Very Happy (looking for the bottle of Aberlour a'bunadh to celebrate that scripting event) *


is it an exchange server?


How did you resolve this BoBo? security workaround, or using Sean's email or some other way?

I know this is an old thread, but the above bump brought it to the top of the stack, and I was interested Smile
Back to top
View user's profile Send private message
randallf



Joined: 06 Jul 2009
Posts: 678

PostPosted: Thu Feb 04, 2010 9:40 pm    Post subject: Reply with quote

This sort of method may be easier on you if you just want to address mails, you'll of course have to adjust it to your own needs...

Code:
EmailRunString := "mailto:" . contactemail . "?subject=" . SubjectString . "&body=" . verbagestring . `%0A`%0A . casedetailsstring  . contactstring
Run, %EmailRunString%
Back to top
View user's profile Send private message
OceanMachine



Joined: 15 Oct 2007
Posts: 780
Location: England

PostPosted: Thu Feb 04, 2010 10:03 pm    Post subject: Reply with quote

Hmm running mailto: - I didn't know about that, very interesting Smile

However, this won't actually send the mail, it will just compose the mail (in the default email program) and wait for me to press the send button, won't it?

I wondered whether he had managed to get a script to send a mail using Outlook, but had somehow bypassed Outlook's security nag ("a program on your computer is trying to send mail, do you want to allow it?" or something like that...)


Last edited by OceanMachine on Thu Feb 04, 2010 10:37 pm; edited 1 time in total
Back to top
View user's profile Send private message
randallf



Joined: 06 Jul 2009
Posts: 678

PostPosted: Thu Feb 04, 2010 10:06 pm    Post subject: Reply with quote

There are ways with COM in excel to bypass the nags, but I don't know if it will work for Outlook:

Code:
COM_Invoke(pxl, "DisplayAlerts", "False")

(especially since it's a security feature tied to the removal of active content in the Outlook reading pane like 3-5 years ago sometime, they went berserk on this security hole because it was causing like fully 90% of virus infections so it might be permanently turned on)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group