Jigs Posted December 2, 2009 Share Posted December 2, 2009 Doing a simple test. I want to open outlook and send "Ctrl-n" to write new mail. Any Clue. ShellExecute("outlook.exe","","","",@SW_MAXIMIZE) WinWait("Outlook") Sleep(5000) SendKeepActive("Outlook") ;~ Send("{CTRLDOWN}N{CTRLUP}") Send("^n") WinWait("Untitled") MsgBox(0,"","ok") Link to comment Share on other sites More sharing options...
martin Posted December 2, 2009 Share Posted December 2, 2009 Doing a simple test. I want to open outlook and send "Ctrl-n" to write new mail. Any Clue. ShellExecute("outlook.exe","","","",@SW_MAXIMIZE) WinWait("Outlook") Sleep(5000) SendKeepActive("Outlook") ;~ Send("{CTRLDOWN}N{CTRLUP}") Send("^n") WinWait("Untitled") MsgBox(0,"","ok") I don't have Outlook but I tried this with Outlook Express WinActivate("Inbox - Outlook") Sleep(5000) SendKeepActive("Inbox - Outlook") ;~ Send("{CTRLDOWN}N{CTRLUP}") Send("^n") WinWait("New Message") MsgBox(0,"","ok") and it worked ok. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 2, 2009 Share Posted December 2, 2009 (edited) @Jigs: You didn't say what happens when you run it. Edited December 2, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Juvigy Posted December 3, 2009 Share Posted December 3, 2009 There are better ways to send mails with outlook: try this one for example: Local $olMailItem = 0 Local $olFormatRichText = 3 Local $olImportanceLow = 0 Local $olImportanceNormal = 1 Local $olImportanceHigh = 2 Local $olByValue = 1 Local $olFormatHTML = 1 $oOApp = ObjCreate("Outlook.Application") $oOMail = $oOApp.CreateItem ($olMailItem) $oOMail.Save With $oOMail .To = ("test1@hp.com") .Recipients.Add("test@hp.com") .Subject = "some subject" .BodyFormat = $olFormatHTML .Importance = $olImportanceNormal .HTMLBody = "the text of the body" .Display ;.Send EndWith Link to comment Share on other sites More sharing options...
Jigs Posted December 3, 2009 Author Share Posted December 3, 2009 @Jigs: You didn't say what happens when you run it. Sorry, I forgot to mention. Actually nothing happens. I suspect that method Send("^n") might be sending key somewhere else or its being send to outlook but no reaction from outlook. Link to comment Share on other sites More sharing options...
Jigs Posted December 3, 2009 Author Share Posted December 3, 2009 There are better ways to send mails with outlook: try this one for example: Local $olMailItem = 0 Local $olFormatRichText = 3 Local $olImportanceLow = 0 Local $olImportanceNormal = 1 Local $olImportanceHigh = 2 Local $olByValue = 1 Local $olFormatHTML = 1 $oOApp = ObjCreate("Outlook.Application") $oOMail = $oOApp.CreateItem ($olMailItem) $oOMail.Save With $oOMail .To = ("test1@hp.com") .Recipients.Add("test@hp.com") .Subject = "some subject" .BodyFormat = $olFormatHTML .Importance = $olImportanceNormal .HTMLBody = "the text of the body" .Display ;.Send EndWith This seems good alternative option and i tried executing code. but i get outlook security window with "Allow" and "Deny" option. Link to comment Share on other sites More sharing options...
jvanegmond Posted December 3, 2009 Share Posted December 3, 2009 Sorry, I forgot to mention. Actually nothing happens. I suspect that method Send("^n") might be sending key somewhere else or its being send to outlook but no reaction from outlook.Perhaps Outlook is busy loading itself, and needs a breather before you choke it with more commands. I know my Outlook takes 5 seconds to boot. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Juvigy Posted December 3, 2009 Share Posted December 3, 2009 This seems good alternative option and i tried executing code. but i get outlook security window with "Allow" and "Deny" option.This is security option.You need to adjust you outlook security settings. I suspect that you dont have antivirus software,it is not updated , or it is disabled.Which outlook do you have - 2007? Link to comment Share on other sites More sharing options...
kaotkbliss Posted December 3, 2009 Share Posted December 3, 2009 I have found that using #include <INet.au3> works flawlessly with my outlook (2007) _INetMail ( $s_MailTo, $s_MailSubject, $s_MailBody ) then Send("{ALT}") Sleep(50) Send("f") Sleep(50) send("e") to automatically send it. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
anixon Posted December 12, 2009 Share Posted December 12, 2009 This seems good alternative option and i tried executing code. but i get outlook security window with "Allow" and "Deny" option. The MAPILab Outlook Security Add-on will resolve the Allow and Deny options otherwise you can use this code which acts as a user agent which you can call and close from your main script. You run it just before you send your email message and close it after the message has been sent. ;//This code runs The Agent Global $pOutlookAgent = @ScriptDir & "\sOutlookAgent.exe" ;//Outlook Security Program [Run] Run($pOutlookAgent) ;//This is the Code that Closes the Agent $PID = ProcessExists($sOutlookAgent) If $PID Then Sleep($SleepSLD) ProcessClose($PID) EndIf expandcollapse popup;//Outlook Agent Opt("TrayIconHide", 1) ;//Hide Tray Icon Opt("WinSearchChildren", 1) ;Search Children [Windows] #include <Date.au3> ;//Date Time Processing ;//Global Variables Global $Title = "sEmailSMS", $Font = "sans-serif", $FontSize = 10, $FontWeight = 600, $Just = 32, $MsgDuration = 4000, $SysMessage, $sExitTimer = 60000 ;//Call the Security Routine _OutlookAgent() ;//Outlook Security Window Processor Func _OutlookAgent() ;//Start the Exit Timer Local $ExitTimer = _TimeToTicks(@HOUR, @MIN, @SEC) + $sExitTimer While 1 ;//Default System Message [Mask] $SysMessage = "The User Security Agent will RESPOND TO the" & @CRLF & "'Microsoft Office Outlook' Pop-Up" & @CRLF & @LF & "Please wait..." ;//Exit when Time Limit Expires If _TimeToTicks(@HOUR, @MIN, @SEC) >= $ExitTimer Then ExitLoop ;//Check for Window If WinExists("Microsoft Office Outlook", "A program is trying to automatically send e-mail") Then ;//Microsoft Office Outlook Window [x, y, width, height] $WinSize = WinGetPos("Microsoft Office Outlook", "A program is trying to automatically send e-mail") SplashTextOn($Title, $SysMessage, $WinSize[2], $WinSize[3], $WinSize[0], $WinSize[1], $Just, $Font, $FontSize, $FontWeight) WinActivate("Microsoft Office Outlook") While 1 If ControlCommand ("Microsoft Office Outlook","A program is trying to automatically send e-mail","Button4","IsEnabled") Then ControlFocus ("Microsoft Office Outlook","","[CLASS:Button; INSTANCE:4]") Send ("{SPACE}") Sleep (500) ;//Message Timer Sleep ($MsgDuration) ;//Switch Message Off SplashOff() ExitLoop EndIf WEnd ;//Reset Exit Timer [Allow OutlookAgent to stay active until all Pop-Ups are Processed] $ExitTimer = _TimeToTicks(@HOUR, @MIN, @SEC) + $sExitTimer EndIf ;//Check for Window If WinExists("Microsoft Office Outlook", "A program is trying to access e-mail addresses you have stored in Outlook") Then $WinSize = WinGetPos("Microsoft Office Outlook", "A program is trying to access e-mail addresses you have stored in Outlook") SplashTextOn($Title, $SysMessage, $WinSize[2], $WinSize[3], $WinSize[0], $WinSize[1], $Just, $Font, $FontSize, $FontWeight) WinActivate("Microsoft Office Outlook") While 1 If ControlCommand ("Microsoft Office Outlook","A program is trying to access e-mail addresses you have stored in Outlook","Button4","IsEnabled") Then ControlFocus ("Microsoft Office Outlook","","[CLASS:Button; INSTANCE:3]") Send ("{SPACE}") Sleep (500) ControlFocus ("Microsoft Office Outlook","","[CLASS:Button; INSTANCE:4]") Send ("{SPACE}") ;//Message Timer Sleep ($MsgDuration) ;//Switch Message Off SplashOff() ExitLoop EndIf WEnd ;//Reset Exit Timer $ExitTimer = _TimeToTicks(@HOUR, @MIN, @SEC) + $sExitTimer EndIf Sleep(1000) WEnd ;//Exit when Time Limit Expires [Note: If running a 'ProcessClose' is Executed by the Calling Program] Exit EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now