Jump to content

Need help to create script for outlook task


Recommended Posts

Sorry, mistake on my side. I updated the code in post #34 (parameter $iOL_ObjectClass is needed).

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

  • Replies 84
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

same error. I don't think the object class for my sample is $olMail. It's not exactly a mail attachment I think.

What I do is drag and drop the au3 file from desktop to the outlook shared folder. It automatically create a item list for me in the shared folder with the au3 file. If you look at it carefully, outlook doesn't list that as a mail attachment. Does that consider a mail?

Link to comment
Share on other sites

Got it! Please replace $olMail with $oldocument.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

_OL_ItemSave($oOutlook, $aItems[1][0], Default, "D:test", $olHTML, 1)

Thank you very much. The script works perfectly. I have also change the $olHTML type to $olMSG instead so I can save the to MSG instead of HTML. Another question, how can I import the msg file back to a specific outlook folder I want. I have try searching in the forum but can't find any information. As far as I know, the only way is to drag and drop the msg file to the outlook folder.

Edited by lolipop
Link to comment
Share on other sites

You call _OL_ItemCreate and pass the MSG as 4th parameter ($sOL_Template).

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

ShellExecute("Outlook", "/profile test2", "", "", @SW_HIDE)
If @error Then Exit MsgBox(16, $sTitle, "Error returned by ShellExecute: " & @error & ", @extended: " & @extended)
Sleep(5000)
$oOutlook = _OL_Open()
If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_Open: " & @error & ", @extended: " & @extended)
$aFolder = _OL_FolderAccess($oOutlook, "*ImportFolder")
If @error Then
    MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended)
    _OL_ItemCreate($oOutlook, $olMailItem, $aFolder, "D:testOutSwitch.au3.msg")
    If @error Then MsgBox(16, $sTitle, "Error returned by _OL_ItemCreate: " & @error & ", @extended: " & @extended) 
Endif
_OL_Close($oOutlook, True)
If @error Then MsgBox(16, $sTitle, "Error returned by _OL_Close: " & @error & ", @extended: " & @extended)

I try using _OL_ItemCreate but it doesn't seems to create the item base on the MSG file. Is the code wrong?

Link to comment
Share on other sites

Try this line please:

_OL_ItemCreate($oOutlook, $olMailItem, $aFolder[1], "D:testOutSwitch.au3.msg")

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

Do you get an error code?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

No problem here (Outlook 2010) to create the item.

Could you please add

$iOL_Debug = 2
at the top of your script after "#include <OutlookEx.au3>"?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

Then no error occurres :oops:

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

yup...no error at all....

The whole script below.

#include <OutlookEx.au3>
$iOL_Debug = 2
$sTitle = "Outlook Test Script"
Global $oOL
; Close all Outlook instances
While 1
    $oOL = ObjGet("", "Outlook.Application")
    If $oOL = 0 Then ExitLoop
    _OL_Close($oOL, True)
WEnd
; Start Outlook with the specified profile
ShellExecute("Outlook", "/profile Outlook", "", "", @SW_HIDE)
If @error Then Exit MsgBox(16, $sTitle, "Error returned by ShellExecute: " & @error & ", @extended: " & @extended)
Sleep(5000)
$oOutlook = _OL_Open()
If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_Open: " & @error & ", @extended: " & @extended)
$aFolder = _OL_FolderAccess($oOutlook, "*Shared Folder")
If @error Then
    MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended)
Else
    $aItems = _OL_ItemFind($oOutlook, $aFolder[1], $olDocument, "", "Subject", "OutSwitch.au3", "EntryID")
    If @error Then
        MsgBox(16, $sTitle, "Error returned by _OL_ItemFind: " & @error & ", @extended: " & @extended)
    Else
        If $aItems[0][0] = 0 Then
            MsgBox(16, $sTitle, "No mail items found!")
        Else
            _OL_ItemSave($oOutlook, $aItems[1][0], Default, "D:test", $olMSG, 1)
  If @error Then MsgBox(16, $sTitle, "Error returned by _OL_ItemSave: " & @error & ", @extended: " & @extended)
        EndIf
    EndIf
Endif
_OL_Close($oOutlook, True)
If @error Then MsgBox(16, $sTitle, "Error returned by _OL_Close: " & @error & ", @extended: " & @extended)
Sleep(5000)
; Start Outlook with the next specified profile
ShellExecute("Outlook", "/profile test1", "", "", @SW_HIDE)
If @error Then Exit MsgBox(16, $sTitle, "Error returned by ShellExecute: " & @error & ", @extended: " & @extended)
Sleep(5000)
$oOutlook = _OL_Open()
If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_Open: " & @error & ", @extended: " & @extended)
$aFolder = _OL_FolderAccess($oOutlook, "*Shared Folder")
If @error Then
    MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended)
    _OL_ItemCreate($oOutlook, $olMailItem, $aFolder[1], "D:testOutSwitch.au3.msg")
    If @error Then MsgBox(16, $sTitle, "Error returned by _OL_ItemCreate: " & @error & ", @extended: " & @extended) 
Endif
_OL_Close($oOutlook, True)
If @error Then MsgBox(16, $sTitle, "Error returned by _OL_Close: " & @error & ", @extended: " & @extended)
Link to comment
Share on other sites

Can you check that the item isn't created in a different folder (like Inbox or drafts folder)?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

If you go to folder "*Shared Folder", right click and select "Properties" what do you get for the "Type" (translated form german - I hope it will be the same in english).

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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 soon running out of ideas :oops:

The item we currently play with is a DocumentItem.

Could you please test with a mail item? That means using the current script and search/save/create a (test) email.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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