SkoubyeWan Posted April 20, 2012 Posted April 20, 2012 Thanks for the reference to _OL_FolderArchiveSet. I will take a look at it. So that what I am doing is clear, I want to be able to select emails (in the usual way with Control-click, etc), then run the script to move the selected emails to a specific folder for more permanent filing. This will make keeping the inbox clean a little easier. Thanks again
water Posted April 21, 2012 Author Posted April 21, 2012 SkoubyeWan, please use function _OL_FolderSelectionGet to get an array of all selected items in the "Active Explorer". You get the object, the EntryId and the objects class you then can process. 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 April 21, 2012 Author Posted April 21, 2012 Just as a follow up, I used the old outlook.au3 UDF and it does not have the same issue with emails or names. Whatever email address is entered is used as entered and no name resolution is even attempted that I can see. Don't know if that helps, but I thought I would throw it out there for you to look at.Thanks.I had a look at the original code written by Wooltown and you are correct: There is no address resolution in function _OutlookSendMail.As I can't reproduce the behaviour here it's impossible to check what's going on.Do you have two address entries which give the error when using my UDF and which work when using the original UDF? If yes, can you please export and send me this contacts? 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 April 21, 2012 Author Posted April 21, 2012 It appears that _OL_ItemAttachmentAdd does not like commas in the path. It returns the following error if there is a comma in the path:Error adding an attachment to the mail @error = 4, @extended = 0Is there a workaround for this? I often use commas in my paths such as "h:Doe, John EP"Thanks.The next version will allow to specify the delimiter as a parameter. 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
SkoubyeWan Posted April 21, 2012 Posted April 21, 2012 SkoubyeWan, please use function _OL_FolderSelectionGet to get an array of all selected items in the "Active Explorer". You get the object, the EntryId and the objects class you then can process. water That was the ticket. Works great. I am not a great coder, but this works for me. Hope it is useful to someone else as well. Mostly taken from the examples. Thank you so much for your help on this. SkoubyeWan Global $oOutlook = _OL_Open() Global $aResult = _OL_FolderSelectionGet($oOutlook) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_FolderSelectionGet", "Error accessing current folder. @error = " & @error & ", @extended = " & @extended) For $Emails = 1 To $aResult[0][0] _OL_ItemMove($oOutlook, $aResult[$Emails][0], Default, "*\Saved to TMR") If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemMove", "Error moving specified emails. @error = " & @error) Next MsgBox(64, "OutlookEX UDF: _OL_ItemMove", "Emails successfully moved to Saved to TMR")
SkoubyeWan Posted April 21, 2012 Posted April 21, 2012 I had a look at the original code written by Wooltown and you are correct: There is no address resolution in function _OutlookSendMail.As I can't reproduce the behaviour here it's impossible to check what's going on.Do you have two address entries which give the error when using my UDF and which work when using the original UDF? If yes, can you please export and send me this contacts?Water,I will see if I can sanitize the problem contacts enough and then send them to you. It may be a little difficult becuase these individuals are in the global address list on the exchange server as well as contacts, but I will see what I can do.Is it possible to provide the users an option to turn off name resolution? I'm not sure how many people are actually using names only rather than full emails, but that would certainly avoid the problem for those who will be inputing full email addresses and don't want any possible confusion.I will get back to you shortly.SkoubyeWan
SkoubyeWan Posted April 21, 2012 Posted April 21, 2012 The next version will allow to specify the delimiter as a parameter.That addition is greatly appreciated.SkoubyeWan
SkoubyeWan Posted April 21, 2012 Posted April 21, 2012 Water,I will see if I can sanitize the problem contacts enough and then send them to you. It may be a little difficult becuase these individuals are in the global address list on the exchange server as well as contacts, but I will see what I can do.Is it possible to provide the users an option to turn off name resolution? I'm not sure how many people are actually using names only rather than full emails, but that would certainly avoid the problem for those who will be inputing full email addresses and don't want any possible confusion.I will get back to you shortly.SkoubyeWanI'm afraid my attempt to sanitize the contacts has not been very successful. On one I had to create a contact from the Global Address List since it did not exist in the contacts. The other was in the contacts. However, when I cleaned everything off it became clear they would not be usefull.I also cannot reproduce the error with other contacts I create. It does seem to be related to the interaction between users in the global address list and the contacts in the address book, not just contacts. All of the errors deal with individuals that are both users on the exchange server and thus in the global address list and contacts in the address book.I believe the solution is to turn off address resolution or at least allow users to turn it off via a switch in the script.Sorry I cannot be more help than that. Thank you for a wonderful UDF.SkoubyeWan
water Posted April 21, 2012 Author Posted April 21, 2012 I will try to create two contacts with the same SMTP mail address. Then I will run my version of the send mail function and the original version by Wooltown. Let's see what happens. 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 April 22, 2012 Author Posted April 22, 2012 I created different contacts with the same SMTP address in diffrerent address books but I couldn't recreate your problem. I'm running Outllok 2010 connected to Exchange 2010 - this might be the problem. If you change variable $sUser to your SMTP address, run the script and press OK on the first GUI what do you get? #AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y #include <outlookex.au3> $iOL_Debug = 2 Global $oOutlook = _OL_Open() Global $sUser = "john.doe@company.com" Global $snd = $oOutlook.Session.GetSelectNamesDialog() $snd.Recipients.Add($sUser) $snd.AllowMultipleSelection = False $snd.Display() 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
SkoubyeWan Posted April 22, 2012 Posted April 22, 2012 I created different contacts with the same SMTP address in diffrerent address books but I couldn't recreate your problem. I'm running Outllok 2010 connected to Exchange 2010 - this might be the problem. If you change variable $sUser to your SMTP address, run the script and press OK on the first GUI what do you get? #AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y #include <outlookex.au3> $iOL_Debug = 2 Global $oOutlook = _OL_Open() Global $sUser = "john.doe@company.com" Global $snd = $oOutlook.Session.GetSelectNamesDialog() $snd.Recipients.Add($sUser) $snd.AllowMultipleSelection = False $snd.Display() The "Select Names" dialog comes up with the email address in the "To->" box. Upon clicking okay, the dialog simply disappears. The email address in the box is correct and I get no errors. I have tried the problem emails and those that are not problems but the results are all the same. The email address that was being translated to another email address is not translated here. I hope this is helpful. SkoubyeWan
water Posted April 22, 2012 Author Posted April 22, 2012 (edited) The script shows the recipient selection dialog with "john.doe@company.com" preset. When you click OK it resolves the adresses like my UDF does. When the resolved address is not unique a second dialog should be displayed to select one of the adresses from the list of ambiguous addresses and so get a unique address. As you don't get the second dialog the email address already is unique. I have to admit that I don't undertstand why the UDF selects a wrong address. I'm in the process of coding a recipient check function. It uses the "resolve" method as does the wrapper function. Maybe this helps us to solve this mystery Edited April 22, 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
SkoubyeWan Posted April 22, 2012 Posted April 22, 2012 In using the _OL_ItemSave function to save emails, if the name used to name the saved email has an email addres in it (say john@testing.com) the file name will cut off anything after the "john@testing" and also truncates the remainder of the file name. I am trying to build file names for the saved emails based on the recipent and the sender. Often the information in these properties are email addresses. I would like to have the entire email address included in the file name and not have the rest of the file name truncated. Is this functioning as it is supposed to? Thanks for any input you might have. SkoubyeWan
water Posted April 22, 2012 Author Posted April 22, 2012 This is caused by function _PathSplit. Looks like it doesn't like more than one dot in a filename #include <File.au3> Global $sOL_Path = "john@testing.com_test_file", $sOL_Drive, $sOL_Dir, $sOL_FName, $sOL_Ext _PathSplit($sOL_Path, $sOL_Drive, $sOL_Dir, $sOL_FName, $sOL_Ext) ConsoleWrite($sOL_FName & @LF) displays "john@testing". The only solution I can think of at the moment is to replace "." with "_" in the filename before calling _OL_ItemSave. 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 April 22, 2012 Author Posted April 22, 2012 (edited) SkoubyeWan, no need to translate the "." to "_". As you only pass drive, path and filename (but no extension) to _OL_ItemSave everything after the dot in the filename is interpreted as extension. Add a dot at the end of the filename and everything will be fine. #include <File.au3> Global $sOL_Path = "c:tempjohn@testing.com_test_file", $sOL_Drive, $sOL_Dir, $sOL_FName, $sOL_Ext _PathSplit($sOL_Path, $sOL_Drive, $sOL_Dir, $sOL_FName, $sOL_Ext) ConsoleWrite($sOL_FName & @LF) $sOL_Path = "c:tempjohn@testing.com_test_file." _PathSplit($sOL_Path, $sOL_Drive, $sOL_Dir, $sOL_FName, $sOL_Ext) ConsoleWrite($sOL_FName & @LF) Edited April 22, 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
SkoubyeWan Posted April 23, 2012 Posted April 23, 2012 Water. That worked like a charm. Thank you so much for all of your help over the last few days. It is greatly appreciated. SkoubyeWan
water Posted April 23, 2012 Author Posted April 23, 2012 Glad to be of service The only problem still unresolved is the strange recipient selection problem, right? 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 April 23, 2012 Posted April 23, 2012 (edited) You can always call function _OL_FolderAccess and then pass element 1 of the returned array to another function. _OL_ItemMove accepts the target folder as a name too but when the folder name starts with "" _OL_FolderAccess (which is called below the covers) needs the folder type too. This parameter isn't passed by _OL_ItemMove - that's why you get the error. Using _OL_FolderAccess and _OL_ItemMove should always work. I added Local $aFolder1 = _OL_FolderAccess($oOutlook, "Correct MailboxInboxInvoice sent by email to X2012-04", $olFolderInbox) _OL_ItemMove($oOutlook, $aItems[$i][0], Default, $aFolder1[1]) .. and it now works great. Edited April 23, 2012 by mdcastle
water Posted April 23, 2012 Author Posted April 23, 2012 I like it when things work as they should 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
SkoubyeWan Posted April 23, 2012 Posted April 23, 2012 (edited) In Response to: Glad to be of service The only problem still unresolved is the strange recipient selection problem, right? _______________________ That is correct. I should mention that it only seems to affect the wrapper function. I am using the following which brings up an email and fills in the "To" with the email and everything works correctly. Global $oItem Global $oOutlook = _OL_Open() $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "", "BodyFormat=" & $olFormatHTML, "Body=" & $BodyFinalWithLink, "Subject=" & $SubjectFinal, "To=" & $StaffEmail, "Importance=" & $olImportanceHigh) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Script", "Error creating mail. @error = " & @error & ", @extended = " & @extended) $oItem = _OL_ItemDisplay($oOutlook, $oItem) The concept of this code is to open an email for the user and fill in some of the information. Then allow the user to finish the email and send it manually. It is interesting, however, that if I add _OL_Close($oOutlook) at the end, it closes the open email on some computers defeating my purpose. Is _OL_Close($oOutlook) absolutely necessary if the user will send the email manually? It seems to work fine without it. Thanks. SkoubyeWan Edited April 23, 2012 by SkoubyeWan
Recommended Posts