mdcastle Posted May 3, 2012 Posted May 3, 2012 (edited) I had manually accessed the mailbox beforehand, but I did that yesterday as well. I've just re-run the script with Outlook open beforehand and it works fine! When the script failed ConsoleWrite("Successfull: " & $oOL_Folder.folderpath & @CRLF) outputted 'Succesfull' to the level above the folder I want to move the email to i.e. Correct MailboxInboxInvoices sent to Supplier2 Edited May 3, 2012 by mdcastle
water Posted May 3, 2012 Author Posted May 3, 2012 Very strange. If you get error 4 the Consolwrite looks like it can access the mailbox plus the first folder successfully. It seems to have the problem with the last folder. Is there something special about the last folder? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
mdcastle Posted May 3, 2012 Posted May 3, 2012 (edited) not that I'm aware of. I'll persevere with it. Its no great hassle to close Outlook down to run the script as it saves me so much more time than having to manually forward emails and move them to various folders. I might even add a bit to the beginning of the script that closes then re-opens Outlook if it continues to be a problem Edited May 3, 2012 by mdcastle
water Posted May 3, 2012 Author Posted May 3, 2012 That's the kind of problem that shouldn't exist - I hate such problems There should be no difference if Outlook is started by the script or manually. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
pickypiglet Posted May 7, 2012 Posted May 7, 2012 Hi There,I'm new to Autoit and I think I've posted in the wrong place initially so re-posting to this thread to hopefully get an answer.Tried to use _OL_ItemExport function to get items from my calendar. It returns a .csv.However, when I try to export the Body/Description it puts on a separate line even though it is the same item. The reason is because the Body of the Calendar item has <enter>. So one calender item is now showing as several lines in my .csv file.How can I keep it on the same line or change the row delimiter? I could only find the field delimiter option for this function.Here's my code snippet:$aData= _OL_ItemFind($oOutlook, "*Calendar", $olAppointment, "[start]>='"&$start&"'", "", "", "Subject,Start,End,Body", "", 2)If @error <> 0 Then Exit MsgBox(16, "", "Error getting calendar from folder '*Calendar'. @error = " & @error & ", @extended = " & @extended)Global $iResult = _OL_ItemExport($filename, "~", "", 1, "Subject,Start,End,Body", $aData)If @error <> 0 Then Exit MsgBox(16, "", "Error exporting Calendar to file. @error = " & @error & ", @extended = " & @extended)MsgBox(64, "", $iResult & " Calendar successfully exported to file")Thx in advance!!
Zedna Posted May 7, 2012 Posted May 7, 2012 Hi There, I'm new to Autoit and I think I've posted in the wrong place initially so re-posting to this thread to hopefully get an answer. Tried to use _OL_ItemExport function to get items from my calendar. It returns a .csv. However, when I try to export the Body/Description it puts on a separate line even though it is the same item. The reason is because the Body of the Calendar item has <enter>. So one calender item is now showing as several lines in my .csv file. How can I keep it on the same line or change the row delimiter? I could only find the field delimiter option for this function. Here's my code snippet: $aData= _OL_ItemFind($oOutlook, "*Calendar", $olAppointment, "[start]>='"&$start&"'", "", "", "Subject,Start,End,Body", "", 2) If @error <> 0 Then Exit MsgBox(16, "", "Error getting calendar from folder '*Calendar'. @error = " & @error & ", @extended = " & @extended) Global $iResult = _OL_ItemExport($filename, "~", "", 1, "Subject,Start,End,Body", $aData) If @error <> 0 Then Exit MsgBox(16, "", "Error exporting Calendar to file. @error = " & @error & ", @extended = " & @extended) MsgBox(64, "", $iResult & " Calendar successfully exported to file") Thx in advance!! $aData= _OL_ItemFind($oOutlook, "*Calendar", $olAppointment, "[Start]>='"&$start&"'", "", "", "Subject,Start,End,Body", "", 2) ; ... here replace all @CRLF to "space" in column Body for all rows of array $aData ... Global $iResult = _OL_ItemExport($filename, "~", "", 1, "Subject,Start,End,Body", $aData) Resources UDF ResourcesEx UDF AutoIt Forum Search
pickypiglet Posted May 7, 2012 Posted May 7, 2012 Thx Zedna! ok. That makes sense. However, I'm new to Autoit. What is the most efficient way to change the body fields and replace with spaces? Is a loop the only way to do it? Thx so much!
Zedna Posted May 7, 2012 Posted May 7, 2012 Is a loop the only way to do it?Yes. Resources UDF ResourcesEx UDF AutoIt Forum Search
mdcastle Posted May 8, 2012 Posted May 8, 2012 (edited) I'm getting @error = 1, @extended = -2147221005 when runningGlobal $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "Connect to Outlook", "Error connecting to Outlook. @error = " & @error & ", @extended = " & @extended) This has just started happening in Outlook 2010, for no apparent reason. The error is generated when the script is run with Outlook already running and also when Outlook is not running. Can anyone help? BTW - i'm also using Windows 7 Edited May 8, 2012 by mdcastle
davidph Posted May 8, 2012 Posted May 8, 2012 (edited) I'm trying to send an email as part of a script to an internal MS exchange mailbox. My code is#include <OutlookEx.au3> $internalmailbox = "Fred Bloggs" SplashTextOn("Test", "Sending Test Email", 500, 100, -1, -1, 33, "", 16) Sleep(2000) SplashOff() $oOL = _OL_Open() SplashTextOn("Test", "Please click the allow check box, then the" & @LF & "allow button on the email dialog below", 500, 100, -1, 200, 33, "", 16) _OL_Wrapper_SendMail($oOL, $internalmailbox, "", "", "Test email", "<b>Test</b>", "", $olFormatHTML) _OL_Close($oOL) SplashOff() Do $process = ProcessExists("OUTLOOK.EXE") Until $process = 0 ; Until process is goneIf I run the code as the same user as the internal mailbox, it works. If I run the code as a different user, it doesn't. No email is sent, and if I open outlook there is a message in the outbox with no receipient in the To field.It also works OK if I use an external email address (bob@company.com), but not for users within the organisation (eg, I can't use the external email address of "Fred Bloggs" above).How can I send an email to a different internal email mailbox?Thanks,David Edited May 8, 2012 by davidph
water Posted May 8, 2012 Author Posted May 8, 2012 Thx Zedna!ok. That makes sense.However, I'm new to Autoit.What is the most efficient way to change the body fields and replace with spaces?Is a loop the only way to do it?Thx so much!I would suggest to replace @CRLF not with spaces but with a character which does not appear in the items body and which you later can replace with a @CRLF again e.g. "|". My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted May 8, 2012 Author Posted May 8, 2012 I'm getting @error = 1, @extended = -2147221005 when runningGlobal $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "Connect to Outlook", "Error connecting to Outlook. @error = " & @error & ", @extended = " & @extended) This has just started happening in Outlook 2010, for no apparent reason. The error is generated when the script is run with Outlook already running and also when Outlook is not running. Can anyone help? BTW - i'm also using Windows 7 Error -2147221005 (decimal) stands for 0x800401F3 (hex): "Unknown Error". Can you please run your script with statement $iOL_Debug = 2after the #include statement so we can get as much error information as possible? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted May 8, 2012 Author Posted May 8, 2012 I'm trying to send an email as part of a script to an internal MS exchange mailbox. My code is You need to do some error checking: #include <OutlookEx.au3> $internalmailbox = "Fred Bloggs" $oOL = _OL_Open() If @error Then Exit MsgBox(16, "Error", "Error returned by _OL_Open. @error = " & @error & ", @extended = " & @extended) _OL_Wrapper_SendMail($oOL, $internalmailbox, "", "", "Test email", "<b>Test</b>", "", $olFormatHTML) If @error Then Exit MsgBox(16, "Error", "Error returned by _OL_Wrapper_SendMail. @error = " & @error & ", @extended = " & @extended) _OL_Close($oOL) If @error Then Exit MsgBox(16, "Error", "Error returned by _OL_Close. @error = " & @error & ", @extended = " & @extended) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
mdcastle Posted May 9, 2012 Posted May 9, 2012 (edited) water I've added the statement so the first few lines of code are; Include Functions #include <OutlookEX.au3> #include <OutlookEXConstants.au3> #include <GUIconstants.au3> $iOL_Debug = 2 However there is no additional output to the console and the @error and @extended error codes are the same. Am I looking in the wrong place for output from $iOL_Debug = 2? Edit - just realised "2" is output to MsgBox (there was no MsgBox generated when the error was created). I changed it to 1 and there was no additional output to console - only ended.rc:1 Exit code: 1 Edited May 9, 2012 by mdcastle
water Posted May 9, 2012 Author Posted May 9, 2012 oItem = _OL_ItemCreate($oOutlook, $olMailItem, "*Outlook-UDF-TestTargetFolderMail", "", "Subject=TestMail", "BodyFormat=" & $olFormatHTML, _ "HTMLBody=Bodytext in <b>bold</b><img src='cid:The_Outlook.jpg'>Embedded image.") If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error creating a mail in folder 'Outlook-UDF-TestTargetFolderMail'. @error = " & @error & ", @extended = " & @extended) $oItem = _OL_ItemAttachmentAdd($oOutlook, $oItem, Default, @ScriptDir & "The_Outlook.jpg") ; , @ScriptDir & "_OL_ItemCopy.au3, 4", @ScriptDir & "_OL_Foldertree.au3") If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error adding an attachment to a mail in folder 'Outlook-UDF-TestTargetFolderMail'. @error = " & @error & ", @extended = " & @extended) ist not working with Outlook 2010 > the email ist created but no attachments! Pls Help. What @error and @extended do you get in the MsgBox? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted May 9, 2012 Author Posted May 9, 2012 (edited) @mdcastle, I wonder why you get @error = 1 and @extended = -2147221005 but the MsgBox doesn't pop up. @error = 1 is only possible when Outlook is started by _OL_Open. Can you please post a stripped down script that reproduces the error at your site? Edited May 9, 2012 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted May 9, 2012 Author Posted May 9, 2012 water I've added the statement so the first few lines of code are[autoit]; Include Functions #include <OutlookEX.au3> #include <OutlookEXConstants.au3> BTW: You don't have to include OutlookEXConstants.au3. That's already done by OutlookEX.au3. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
mdcastle Posted May 9, 2012 Posted May 9, 2012 #include <OutlookEX.au3> $iOL_Debug = 2 ; Connect to Outlook Global $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "Connect to Outlook", "Error connecting to Outlook. @error = " & @error & ", @extended = " & @extended) ; ^^^^^ Error happens after this line ; Access correct mailbox Global $aFolder = _OL_FolderAccess($oOutlook, "Correct MailboxInbox", $olFolderInbox) If @error <> 0 Then Exit MsgBox(16, "Folder access", "Error accessing Correct MailboxInbox. @error = " & @error & ", @extended = " & @extended)
water Posted May 9, 2012 Author Posted May 9, 2012 I see: The sequence of statements in _OL_Open is wrong. hence you don't get a MsgBox. Could you please replace _OL_Open in your UDF with the following code: expandcollapse popupFunc _OL_Open($bOL_WarningClick = False, $sOL_WarningProgram = "", $iOL_WinCheckTime = 1000, $iOL_CtrlCheckTime = 1000, $sOL_ProfileName = "", $sOL_Password = "") Local $iOL_ErrorHandler = 0 Local $oOL = ObjGet("", "Outlook.Application") If $oOL <> 0 Then $bOL_AlreadyRunning = True If Not IsBool($bOL_WarningClick) Then Return SetError(3, 0, 0) If Not IsInt($iOL_WinCheckTime) Then Return SetError(4, 0, 0) If Not IsInt($iOL_CtrlCheckTime) Then Return SetError(7, 0, 0) ; A COM error handler will be initialised only if one does not exist If ObjEvent("AutoIt.Error") = "" Then $oOL_Error = ObjEvent("AutoIt.Error", "_OL_COMError") ; Creates a custom COM error handler If @error Then Return SetError(2, @error, 0) $iOL_ErrorHandler = 1 EndIf If $bOL_AlreadyRunning And $sOL_ProfileName <> "" Then Return SetError(10, 0, 0) If Not $bOL_AlreadyRunning Then $oOL = ObjCreate("Outlook.Application") If @error Or Not IsObj($oOL) Then Return SetError(1, @error, 0) EndIf If $bOL_WarningClick Then If StringStripWS($sOL_WarningProgram, 3) = "" Then $sOL_WarningProgram = @ScriptDir & "_OL_Warnings.exe" If Not FileExists($sOL_WarningProgram) Then Return SetError(5, 0, 0) Run($sOL_WarningProgram & " " & @AutoItPID & " " & $iOL_WinCheckTime & " " & $iOL_CtrlCheckTime & " " & $oOL.Version & " " & $oOL.LanguageSettings.LanguageID($msoLanguageIDUI), "", @SW_HIDE) If @error Then Return SetError(6, @error, 0) EndIf Local $aVersion = StringSplit($oOL.Version, '.') ; Logon to the specified or the default profile if Outlook wasn't already running (for Outlook 2007 and later) If Not $bOL_AlreadyRunning And Int($aVersion[1]) >= 12 Then If StringStripWS($sOL_ProfileName, 3) = "" Then $sOL_ProfileName = $oOL.DefaultProfileName If StringStripWS($sOL_ProfileName, 3) = "" Then Return SetError(9, 0, 0) Local $oOL_Namespace = $oOL.GetNamespace("MAPI") $oOL_Namespace.Logon($sOL_ProfileName, $sOL_Password, False, False) If @error Then Return SetError(8, @error, 0) EndIf Return SetError(0, $iOL_ErrorHandler, $oOL) EndFunc ;==>_OL_Open My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
mdcastle Posted May 9, 2012 Posted May 9, 2012 COM Error Encountered in AutoForward-New.au3 OutlookEx UDF version = 0.7.1.1 @AutoItVersion = 3.3.8.1 @AutoItX64 = 0 @Compiled = 0 @OSArch = X86 @OSVersion = WIN_7 Scriptline = 188 NumberHex = 800401F3 Number = -2147221005 WinDescription = Invalid class string Description = Source = HelpFile = HelpContext = 1866735648 LastDllError = 1008
Recommended Posts