Sign in to follow this  
Followers 0
PCrane

Help with Outlook script

12 posts in this topic

I am trying to put together a script to speed up my email sending process. I have come up with a little code that that i need some help with. Outlook opens another outlook even though outlook is already running. How can i get it to only use the current outlook that is already opened? Also, i would like to have a few boxes to popup. Like one for enter email address and ok and that places that information into the TO section. One for the CC and one for the Subject section? I am new to this. Please help me with this.

; Script Start - Add your code below here
$g_szVersion = "Automated Email Send"
If WinExists($g_szVersion) Then Exit; It's already running
AutoItWinSetTitle($g_szVersion)

Run("C:\Program Files\Microsoft Office\OFFICE11\outlook.exe")

WinWaitActive("Inbox - Microsoft Outlook")
Send("^n")
WinWaitActive("Untitled - Message (Plain Text)")
Send("email address")
Send("{TAB 3}")
Send("This is a test email")
Send("{TAB}")
Send("Hows it going? This is my script email!")

Share this post


Link to post
Share on other sites



What's the use of this?

$g_szVersion = "Automated Email Send"
If WinExists($g_szVersion) Then Exit; It's already running
AutoItWinSetTitle($g_szVersion)

Share this post


Link to post
Share on other sites

Script i found to make sure no other instance of the script will run at the same time.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

You can use _Singleton instead. Look it in the help file.

EDIT:

If Not WinExists("Inbox - Microsoft Outlook") Then Run("C:\Program Files\Microsoft Office\OFFICE11\outlook.exe")
Send("^n")
WinWaitActive("Untitled - Message (Plain Text)")
Send("email address")
Send("{TAB 3}")
Send("This is a test email")
Send("{TAB}")
Send("Hows it going? This is my script email!")

EDIT: You can use

If Not WinExists("Inbox - Microsoft Outlook") Then Run("C:\Program Files\Microsoft Office\OFFICE11\outlook.exe")

or

If WinExists("Inbox - Microsoft Outlook") = 0 Then Run("C:\Program Files\Microsoft Office\OFFICE11\outlook.exe")

It's the same.

Edited by Aassdd

Share this post


Link to post
Share on other sites

Ok thanks. Any ideas on the inputbox for the TO, CC and subject lines?

Share this post


Link to post
Share on other sites

Try pressing alt when you are in the new email window. Or try ControlSend.

Share this post


Link to post
Share on other sites

Ok, what am i missing here, with outlook is already open on my machine, but when running the script it opens another outlook program?

If WinExists("Inbox - Microsoft Outlook") = 0 Then Run("C:\Program Files\Microsoft Office\OFFICE11\outlook.exe")

Run("C:\Program Files\Microsoft Office\OFFICE11\outlook.exe")

WinWaitActive("Inbox - Microsoft Outlook")
Send("^n")
WinWaitActive("Untitled - Message (Plain Text)")
$answer = InputBox("TO:","Enter Email Address")
Sleep(200)
Send($answer)
Send("{TAB}")
$answer = InputBox("CC:","Enter Email Address")
Sleep(200)
Send($answer)
Send("{TAB}")
$answer = InputBox("BCC:","Enter Email Address")
Sleep(200)
Send($answer)
Send("{TAB}")
$answer = InputBox("SUBJECT:","Enter Subject")
Sleep(200)
Send($answer)
Send("{TAB}")

Share this post


Link to post
Share on other sites

If ProcessExists("Outlook.exe") Then

MsgBox(4096,"", "Outlook is running")

; You can enter your code here

Else

MsgBox(4096,"","Outlook is not running, Now Open Outlook")

$Outlook_Path = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE", "") ; Read in the location of Outllook and us the deafult key

MsgBox(4096,"",$Outlook_Path)

Run($Outlook_Path)

; You can enter your code here

EndIf

Share this post


Link to post
Share on other sites

If ProcessExists("Outlook.exe") Then

MsgBox(4096,"", "Outlook is running")

; You can enter your code here

Else

MsgBox(4096,"","Outlook is not running, Now Open Outlook")

$Outlook_Path = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE", "") ; Read in the location of Outllook and us the deafult key

MsgBox(4096,"",$Outlook_Path)

Run($Outlook_Path)

; You can enter your code here

EndIf

Why is the e-mail adress not coming up?

Below is the code am I missing something?

WinWaitActive("Inbox - Microsoft Outlook")

Sleep(900)

Send("+{UP 4}")

Sleep(2000)

Send("^n")

WinWaitActive("Untitled - Message (Plain Text)")

Sleep(900)

$answer = InputBox("TO...:","Enter Email Address")

Share this post


Link to post
Share on other sites

I may not have understood your goal correctly, but I would use as simple script that makes the mail and send it like

$myOlApp = ObjCreate("Outlook.Application")
$myItem = $myOlApp.Application.CreateItem(0)
$myItem.Display
$myItem.To = "test@email.com"
$myItem.Subject = "This is the subject"
$myItem.Body = "Hello World!"

This would speed up your email sending process and it would not open a new process for the outlook.exe.

Share this post


Link to post
Share on other sites

Using COM Outlokk will popup a security cuestion. It can be circumvented by Send commands on the security question or using 3rd party component that disables Outlook COM automation blockings.

Share this post


Link to post
Share on other sites

you could use the redemption outlook COM object, http://www.dimastr.com/redemption/

Its able to get around the security popup just fine.

CODE
$olookApp = ObjCreate("Outlook.Application")

$oItem = $olookApp.CreateItem(0)

$SafeItem.Item = $oItem

$SafeItem.Recipients.Add("email@address.com")

$SafeItem.Subject = "Testing"

$SafeItem.Body = "Body Text Here"

$SafeItem.Send

Ive used it to make a script that checks for new mail, open the message, download attachment, reply to messages, etc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0