Hi jos,
I try to clarify. I ve used the example script below. It works fine : connect to the mail box, find the mails unread and send them to a external address. I see outlook display the message "sending mail...". But the mail doesn't arrive in the external mailbox. I don't know exactly what blocks ( a admin rule on the exchange server?). I ve tried with a rule in Outlook to forward automatically some mails. This gives the same result. When i forward the mail manualy to the external mailbox, it works. That why, i am interested in Outlookex_udf to simulate a manual sending..
Thanks for your answer...
; Include Functions
#include <OutlookEX.au3>
Global $oForward, $sRecipient = "John.Doe@company.com"
; 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 Mailbox\Inbox", $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, $sRecipient) ; Add recipient
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)
Next
; Close connection to Outlook
_OL_Close($oOutlook)