Jump to content

Help with Outlook script


Recommended Posts

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!")
Link to comment
Share on other sites

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
Link to comment
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}")
Link to comment
Share on other sites

  • 3 weeks later...

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

Link to comment
Share on other sites

  • 2 weeks later...

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")

Link to comment
Share on other sites

  • 1 month later...

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.

Link to comment
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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...