Jump to content

OutlookEX UDF - Help & Support


Recommended Posts

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.

Link to comment
Share on other sites

The work you have done with this UDF is so good that I hesitate to submit a request for additional functionality, but here it goes anyway.

It would be wonderful to have the functionality that allows for the insertion of a hyperlink in the body of an email. Attachments are great, but sometimes you just want to insert a link in the body of the text. Perhaps there is already a way to do this that I'm unaware of.

Thanks for all you do.

Link to comment
Share on other sites

If you want to add an attachment as a reference/link to the real file you set parameter "Type" for the attachment to $olByReference in function _OL_ItemAttachmentAdd.

; OlAttachmentType Enumeration. Specifies the attachment type.
; See: http://msdn.microsoft.com/en-us/library/bb208055(v=office.12).aspx
Global Const $olByReference = 4 ; The attachment is a shortcut to the location of the original file
Global Const $olByValue = 1 ; The attachment is a copy of the original file and can be accessed even if the original file is removed
Global Const $olEmbeddeditem = 5 ; The attachment is an Outlook message format file (.msg) and is a copy of the original message
Global Const $olOLE = 6 ; The attachment is an OLE document
Edited 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

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 will have a look and hopefully I can see why he old version works without problems ;)

Unfortunately I can't reproduce your problem here - so finding the problem might become a bit tricky.

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

Version 0.7.1.1 (Bugfixes) of the UDF has been released.

Please test before using in production!

For download please see my signature.

Edited 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

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 = 0

Is there a workaround for this? I often use commas in my paths such as "h:Doe, John EP"

Thanks.

Link to comment
Share on other sites

The function accepts up to 4 sub-parameters per attachment separated by a comma: "Every attachment parameter can consist of up to 4 sub-parameters separated by commas:"

A quick and dirty solution would be to change the function in the UDF. Replace line

Local $aOL_Temp = StringSplit($aOL_Attachments[$iOL_Index], ",")
with something like:
Local $aOL_Temp = StringSplit($aOL_Attachments[$iOL_Index], "|") ; changed separator from comma to pipe character

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

Okay. That would work.

Would this also change the separator for the other parameters of the function? Or just for the sub parameters for attachments? If it is just for the sub-parameters of the attachment, you might consider a differents seperator for your final UDF. Perhaps one that is not includable in file names, such as the colon. Just a thought.

Thanks again for all your help.

Link to comment
Share on other sites

The change I proposed above only affects the sub parameters for attachments.

I might add a new parameter to functions working with separators or a new function which globaly sets the separator. Haven't made up my mind yet.

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

Example script to add the first available category to all mail items of a folder:

#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
#include <OutlookEX.au3>

; *****************************************************************************
; Create test environment
; *****************************************************************************
Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF - Manage Test Environment", "Error creating connection to Outlook. @error = " & @error & ", @extended = " & @extended)
Global $Result = _OL_TestEnvironmentCreate($oOutlook)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF - Manage Test Environment", "Error creating the test environment. @error = " & @error & ", @extended = " & @extended)

; Access a mail folder of the test environment
Global $aFolder = _OL_FolderAccess($oOutlook, "*Outlook-UDF-TestSourceFolderMail")
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: Example Script", "Error accessing folder 'Outlook-UDF-TestSourceFolderMail'. @error = " & @error & ", @extended = " & @extended)

; Get a list of categories
Global $aCategories = _OL_CategoryGet($oOutlook)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: Example Script", "Error getting alist of available categories. @error = " & @error & ", @extended = " & @extended)
If $aCategories[0][0] = 0 Then Exit MsgBox(16, "OutlookEX UDF: Example Script", "No categories found.")

; Get all mail items
Global $aItems = _OL_ItemFind($oOutlook, $aFolder[1], $olMail, "", "", "", "EntryID,Categories")
If @error <> 0 Then Exit MsgBox(48, "OutlookEX UDF: Example Script", "Didn't find any emails. @error = " & @error & ", @extended: " & @extended)

; Set categories of every mail item
For $i = 1 To $aItems[0][0]
    If $aItems[$i][1] = "" Then
        _OL_ItemModify($oOutlook, $aItems[$i][0], Default, "Categories=" & $aCategories[1][5]) ; item has no category. Set new one
    Else
        _OL_ItemModify($oOutlook, $aItems[$i][0], Default, "Categories=" & $aItems[$i][1] & "," & $aCategories[1][5]) ; item has categories. Add new one
    EndIf
    If @error <> 0 Then Exit MsgBox(48, "OutlookEX UDF: Example Script", "Error updating item. @error = " & @error & ", @extended: " & @extended)
Next

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

I'm very new to AutoIt so please bear with me.

I have a requirement to look for unread items in a specific mailbox then loop through these emails and forward each one to a specific email address outside of our organisation.

I'm stuck on how to specify the 'to' address on the forwarded email, so any help would be appreciated.

My script so far is (made up from the help files):

#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
;Include Functions
#include <OutlookEX.au3>
#include <OutlookEXConstants.au3>
;create connection to Outlook
Global $oOutlook = _OL_Open()
;Move to correct mailbox
Global $aFolder = _OL_FolderAccess($oOutlook, "Correct MailboxInbox", $olFolderInbox)
;Set correct mailbox as current folder
_OL_FolderSet($oOutlook, $aFolder[1])
If @error <> 0 Then Exit MsgBox(16, "Setting Folder", "Error setting folder. @error = " & @error & ", @extended = " & @extended)
;Get unread items
$aItems = _OL_ItemFind($oOutlook, $aFolder[1], $olMail, "[UnRead]=True", "", "", "Subject,Body", "", 4)
Msgbox(0, "Number of unread items", $aItems)
Global $aOL_Item = _OL_ItemFind($oOutlook, $aFolder[1], $olMail, "", "", "", "EntryID")
If $aOL_Item[0][0] = 0 Then Exit MsgBox(16, "Error", "No mail items in Correct Mailbox Inbox. @error = " & @error)
Global $oResult = _OL_ItemForward($oOutlook, $aOL_Item[1][0], Default, "")
If @error <> 0 Then Exit MsgBox(16, "Error", "Error forwarding mail item in Correct Mailbox Inbox. @error = " & @error & ", @extended = " & @extended)
; Display item to forward
$oResult.Display
Edited by mdcastle
Link to comment
Share on other sites

Hi mdcastle,

_OL_ItemForward just creates a copy of the item. You then have to add the recipient and send the item. My documentation could be a bit better ;)

Here is a working example that sends all unread mail of a folder to a specified user:

#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y

; Include Functions
#include <OutlookEX.au3>
#include <OutlookEXConstants.au3>
Global $oForward

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

; Access correct mailbox
Global $aFolder = _OL_FolderAccess($oOutlook, "Correct MailboxInbox", $olFolderInbox)
If @error <> 0 Then Exit MsgBox(16, "Folder access", "Error accessing the mailbox. @error = " & @error & ", @extended = " & @extended)

; Get unread items
Global $aItems = _OL_ItemFind($oOutlook, $aFolder[1], $olMail, "[UnRead]=True", "", "", "EntryID,Subject,Body")
If @error <> 0 Then Exit MsgBox(16, "Item find", "Error searching for unread mail items. @error = " & @error & ", @extended = " & @extended)
MsgBox(0, "Number of unread items", $aItems[0][0])
If $aItems[0][0] = 0 Then Exit MsgBox(16, "Error", "No mail items in Correct Mailbox Inbox.")

; Forward all unread mails
For $i = 1 To $aItems[0][0]
    $oForward = _OL_ItemForward($oOutlook, $aItems[$i][0], Default, "") ; Create a copy of the item to forward
    If @error <> 0 Then Exit MsgBox(16, "Item forward", "Error creating an item copy to forward. @error = " & @error & ", @extended = " & @extended)
    _OL_ItemRecipientAdd($oOutlook, $oForward, Default, $olTo, "Enter the name of the recipient here") ; Add recipient here <===========
    If @error <> 0 Then Exit MsgBox(16, "Recipient add", "Error adding a recipient to the mail item. @error = " & @error & ", @extended = " & @extended)
    _OL_ItemSend($oOutlook, $oForward) ; Send the item to the recipient
    If @error <> 0 Then Exit MsgBox(16, "Item send", "Error sending the mail item. @error = " & @error & ", @extended = " & @extended)
    $oForward.Display
Next

; Close connection to Outlook
_OL_Close($oOutlook)
Edited 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

Thank you so much. Forgive my cheekiness but i'm now trying to build upon the script a bit more.

I've added:

_OL_ItemMove($oOutlook, $aItems[$i][0], Default, "Correct MailboxInboxInvoice sent by email to X2012-04")
If @error <> 0 Then Exit MsgBox(16, "Item move", "Error moving the mail item. @error = " & @error & ", @extended = " & @extended)

before the 'Next' to move the forwarded email to a folder, but when the script is run i get @error =1, @extended = 1.

In the documentation for _OL_ItemMove is says that $vOL_TargetFolder can be the full name of the folder but it doesn't seem to work. Can you shed any light on why? Could it be because I don't have a _OL_FolderAccess calling the folder I want to move the email to?

Link to comment
Share on other sites

You get this error because _OL_FolderAccess can't access the target folder.

I will verify the function and check for possible errors tomorrow.

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

Is "Correct Mailbox" the mailbox of the user running the script?

If yes could you please replace

"Correct MailboxInboxInvoice sent by email to X2012-04")
with
"*InboxInvoice sent by email to X2012-04")

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

Could it be because I don't have a _OL_FolderAccess calling the folder I want to move the email to?

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.

Edited 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

Is "Correct Mailbox" the mailbox of the user running the script?

No, unfortunately not.

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'll give it a go. Many thanks for your support.

Edited by mdcastle
Link to comment
Share on other sites

I'm trying to create a script to move emails in Outlook to a specified directory. I have read everything I could on the Wiki and this forum, but I cannot seem to find out how to use _OL_ItemFind to identify emails that are highlighted. Once I figure that out, I think it should be relatively streight forward to use _OL_ItemMove to move those Items to a specified folder. I'm sure I am overlooking something. Perhaps one of you already have a script that does this. I'm just trying to simplify the filing process of emails.

Any help would be most appreciated.

Thanks.

SkoubyeWan

Link to comment
Share on other sites

Should be possible. I will come up with a solution tomorrow.

BTW: You could have a look at function _OL_FolderArchiveSet. It allows to set archiving options for a folder.

Edited 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

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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