water Posted March 12, 2012 Author Share Posted March 12, 2012 However, the FolderPath property of the _OL_PSTAccess returned object can't be used as folder path so all references to folder have to be objects.Thats's true for folders on an IMAP server or Exchange. _OL_FolderAccess returns the object which you pass to all other functions (you could pass the name which internally is replaced by _OL_FolderAccess).Also I'm wondering if the results I got with _OL_ItemMove and _OL_FolderMove are strange; instead of moving items they create new items in target folders and delete the original items to "Deleted Items" folder in Outlook thus result in duplacate copies of the same items on the IMAP server (since the "Deleted Items" is considered a customer folder on the IMAP server while deleted items on the IMAP server are under a system folder called "Trash").I don't know if this is default behaviour for IMAP. On Exchange the item is simply moved.How do you call _OL_ItemMove? 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 Link to comment Share on other sites More sharing options...
water Posted March 12, 2012 Author Share Posted March 12, 2012 (edited) I searched the web and found the following site stating: "Because of the way IMAP works, when Outlook moves an item to another folder, it actually copies the item and marks the original for deletion."So it seems to be IMAP specific. Edited March 12, 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 Link to comment Share on other sites More sharing options...
thisca Posted March 14, 2012 Share Posted March 14, 2012 I am trying to get emails from outlook into AutoIt and need help getting the email header property. This is the script that I am using (it works for the fields listed): #include <array.au3> #include <OutlookEX.au3> $oOutlook = _OL_Open() $aItems = _OL_ItemFind($oOutlook, "*\Inbox", $olMail, '[Subject]="Test"', "", "", "Subject,Body,To,SenderEmailAddress,EntryID,CreationTime,SentOn,SenderName", "", 1) If IsArray($aItems) Then _ArrayDisplay($aItems, @ScriptLineNumber) EndIf My problem is that the email header is not a standard property that I can include in the properties list. From internet search, it appears that the header information from Outlook emails is available with: PropertyAccessor.GetProperty, and the property is: PR_MAIL_HEADER_TAG. I do not know how to format this to include it in the _OL_ItemFind function call or how to modify the _OL_ItemFind function to return this information. Any suggestions? Thanks Link to comment Share on other sites More sharing options...
water Posted March 14, 2012 Author Share Posted March 14, 2012 I will have a look at it tomorrow. I've never done it before but I think it should be possible. Can you post some of the links you've found? 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 Link to comment Share on other sites More sharing options...
water Posted March 15, 2012 Author Share Posted March 15, 2012 (edited) @Thisca Yes. This example writes the header info of the first mail of the inbox to the console. #include <OutlookEX.au3> Global $oOutlook = _OL_Open() Global $aItems, $aFolder $aFolder = _OL_FolderAccess($oOutlook, "", $olFolderInbox) If @error Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended) $aItems = _OL_ItemFind($oOutlook, $aFolder[1], $olMail, "", "", "", "EntryID", "", 1) If Not IsArray($aItems) Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended) Global $sPR_MAIL_HEADER_TAG = "http://schemas.microsoft.com/mapi/proptag/0x007D001E" Global $oMail = $oOutlook.Session.GetItemFromID($aItems[1][0]) Global $oOL_PA = $oMail.PropertyAccessor Global $sMailheader = $oOL_PA.GetProperty($sPR_MAIL_HEADER_TAG) ConsoleWrite(">" & $sMailheader & "<" & @CRLF) Edited March 15, 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 Link to comment Share on other sites More sharing options...
xian7479 Posted March 15, 2012 Share Posted March 15, 2012 I searched the web and found the following site stating: "Because of the way IMAP works, when Outlook moves an item to another folder, it actually copies the item and marks the original for deletion."So it seems to be IMAP specific.Thanks for searching for the info! Yes it seems to be how Outlook COM deals with IMAP folders. However, it doesn't have such problem when use the functions from the menu or just simply drag & drop inside Outlook. The way I call the _OL_ItemMove or _OL_FolderMove is just the standard way and I even tried to use the Move method directly on the object of the item or the MoveTo method on the folders (which is essentially the same as your functions only omitted all those checks just want to see if that could make a difference) and still got the same result. The method described in the article to move the items to Trash doesn’t really help as it actually creates another copy so I wrote a script to access the email through web interface every 4 hours to delete all items in the Deleted Items folder also clean those items from Trash at the same time. I got it working properly for the purpose I intended and thanks for your help. I’m going to get a bit more work done by using the Outlook UDF and I’ll be back if I have anymore questions.Thanks again!Danny Link to comment Share on other sites More sharing options...
water Posted March 15, 2012 Author Share Posted March 15, 2012 Glad to be of service If you have further questions just post here and I will do my very best. 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 Link to comment Share on other sites More sharing options...
water Posted March 15, 2012 Author Share Posted March 15, 2012 @Thisca I'm going to implement this as a new function in the UDF. ; #FUNCTION# ==================================================================================================================== ; Name ..........: _OL_MailheaderGet ; Description ...: Get the headers of an mail item using the specified EntryID and StoreID. ; Syntax.........: _OL_MailheaderGet($oOL, $vOL_Item[, $sOL_StoreID]) ; Parameters ....: $oOL - Outlook object returned by a preceding call to _OL_Open() ; $vOL_Item - EntryID or object of the mail item ; $sOL_StoreID - Optional: StoreID of the source store as returned by _OL_FolderAccess (default = keyword "Default" = the users mailbox) ; Return values .: Success - Mail headers ; Failure - Returns "" and sets @error: ; |1 - Error getting the mail object from the specified EntryID and StoreID ; Author ........: water ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _OL_MailheaderGet($oOL, $vOL_Item, $sOL_StoreID = Default) Local $sPR_MAIL_HEADER_TAG = "http://schemas.microsoft.com/mapi/proptag/0x007D001E" If Not IsObj($vOL_Item) Then $vOL_Item = $oOL.Session.GetItemFromID($vOL_Item, $sOL_StoreID) If @error Then Return SetError(1, @error, "") Local $oOL_PA = $vOL_Item.PropertyAccessor Return $oOL_PA.GetProperty($sPR_MAIL_HEADER_TAG) EndFunc ;==>_OL_MailheaderGet 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 Link to comment Share on other sites More sharing options...
water Posted April 9, 2012 Author Share Posted April 9, 2012 Version 0.7.0 of the UDF has been released.Please test before using in production!For download please see my signature. 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 Link to comment Share on other sites More sharing options...
SkoubyeWan Posted April 17, 2012 Share Posted April 17, 2012 Thank you so much for your work on this project. Very useful. I am working with Outlook 2007 and Exchange Server 2007. I am testing your _OL_Wrapper_SendMail wrapper function. It works fine under under version 0.6, but when I installed 0.7, it broke and gave me the following error: @error = 2002, @extended: 6 I went back to 0.6 and works fine again. However . . . there is still one problem I would like to solve. I am setting the email address to send to in a variable called $StaffEmail. The email is set for one person as "deanna@test.com" (just a dummy email for illustration). But the script appears to look up the person and send it to their personal email address instead of the one I selected in the script (ie. deanna@personalemail.com) Here is my code:$iOL_Debug = 2 Global $oOutlook = _OL_Open() _OL_Wrapper_SendMail($oOutlook, $StaffEmail, "", "", $SubjectFinal, $BodyFinal, $AttachFile, $olFormatRichText, $olImportanceHigh) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OutlookSendMail Wrapper Script", "Error sending mail. @error = " & @error & ", @extended: " & @extended) MsgBox(64, "OutlookEX UDF: _OutlookSendMail Wrapper Script", "Mail successfully sent to user '" & $StaffEmail & "'!") _OL_Close($oOutlook) It appears to be checking the address book in Outlook and matching up the name rather than using the email address I am supplying. How can I force it to use the email address as entered? Thank you in advance for your help. I am certainly no AutoIt expert. Sincerely, SkoubyeWan Link to comment Share on other sites More sharing options...
water Posted April 17, 2012 Author Share Posted April 17, 2012 SkoubyeWan, I'm going to test tomorrow as soon as I'm in my office again. I already got the impression that the enhanced error checking in version 0.7.0 might have introduced some errors. Regards 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 Link to comment Share on other sites More sharing options...
water Posted April 18, 2012 Author Share Posted April 18, 2012 (edited) SkoubyeWan, I found the problem and created a new version 0.7.1.0. I don't want to publish this version at the moment because I didn't find time to test as thorough as needed. Could you please give it a try and report any problems you encounter? Thanks Edited May 4, 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 Link to comment Share on other sites More sharing options...
SkoubyeWan Posted April 18, 2012 Share Posted April 18, 2012 Water: Thanks! Your change did fix the wrapper issue. It now works as before. However, I am still struggling with the email address problem. To illustrate the problem further with what I think to be a related problem. If I use an email address to someone who is in the global address list as a contact, and there are similar email addresses in the global address list such as deanna@testing.com deanna2@testing.com The email works fine for deanna2@testing.com because it is unique enough. However, if I use deanna@testing.com, then I get the following error reports and the send fails: COM Error Encountered in TMR - Master. au3 OutlookE UDF vers ion = 0.7.0 @AutoItversion = 3.3.8.1 @AutoItx64 = 0 @Compiled = 0 @OSArch = X86 @OSVersion=WIN_XP Scriptline = 3469 NumberHex = 80020009 Number = -2147352567 WinDescription = Description = Outlook does not recognize one or more names. Source = Microsoft Office Outlook HelpFile = HeIpContext = 0 LastDIlError = 0 Error sending mail. @error = 6022, @extended: -2147352567 I think this is related to the email going to the wrong email address as described in my prior post. The wrapper seems to be checking the email against the address book and then sending the email to the closest match if it comes up with only one, but if there is more than one returning this error. Any insights would be most appreciated. Thanks again for a wonderful UDF. SkoubyeWan Link to comment Share on other sites More sharing options...
water Posted April 18, 2012 Author Share Posted April 18, 2012 Glad version 0.7.1 solved the problem! If you create a new mail in Outlook manually and enter deanna@testing.com as a recipient does Outlook accept this address or do you get a dropdown where you should select an address from a list of similar names? 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 Link to comment Share on other sites More sharing options...
SkoubyeWan Posted April 18, 2012 Share Posted April 18, 2012 As I type, a drop down box appears with different choices. The choices narrow as I type. If I type an email address never used before, the box will disappear completely and leave the email address as is. If I type an email address that I have used before and that is in the contacts list, when I hit tab or enter, it replaces the email address with the name of the person. Link to comment Share on other sites More sharing options...
water Posted April 18, 2012 Author Share Posted April 18, 2012 The addresses you see while you type are from your personal address book where Outlook stores the addresses you have used before. But if you do a copy&paste of "deanna@testing.com" and then verify the address does Outlook see it as unique or does it offer you a dropdown to select from? BTW: I released version 0.7.1 with the bug fixes 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 Link to comment Share on other sites More sharing options...
SkoubyeWan Posted April 18, 2012 Share Posted April 18, 2012 When I copy and past "deanna@testing.com" it offers a dropdown list of only one name item, but the drop down list is there just the same. I have tried turning off the "suggest names while completing To, Cc, and Bcc fields" as well as the "Automatic name checking" in the outlook options. This takes away the popup box, but has no impact on emails being sent to the wrong email address for the person instead of the one entered, or the errors for the particular email address previously described. Link to comment Share on other sites More sharing options...
water Posted April 18, 2012 Author Share Posted April 18, 2012 What happens if you enter the name of the recipient and not the mail address? 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 Link to comment Share on other sites More sharing options...
SkoubyeWan Posted April 18, 2012 Share Posted April 18, 2012 With "suggest names while completing To, Cc, and Bcc fields" as well as the "Automatic name checking" turned back on in outlook options, the autocomplete box comes on and it narrows as you type. Ultimately it will narrow to two choices for those with multiple emails. I also tried using the names in the script and it just returned "Error sending mail. @error = 4004, @extended: 0" Link to comment Share on other sites More sharing options...
water Posted April 18, 2012 Author Share Posted April 18, 2012 Error 4004 is error 4 returned by _OL_ItemRecipientAdd. It means: Recipient name could not be resolved. @extended = number of the invalid recipient (zero based) I don't understand (at the moment) why the name can be resolved when manually added but can't when added using the UDF. More investigation is needed .... 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 Link to comment Share on other sites More sharing options...
Recommended Posts