Jump to content

Need help to create script for outlook task


Recommended Posts

saving as a mail item and import back doesn't work either.

one thing i notice for this particular code

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

changing the above coding for the template/source location doesn't seems to affect the script. Meaning, for example if I change to

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

The file "D:testOutSwitch.au3.msg.123" doesn't exist at all in that folder. But the script complete successfully without any error. Weird....that's why I think my coding is wrong somewhere.

Edited by lolipop
Link to comment
Share on other sites

  • Replies 84
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Another question: What version of the UDF do you use? Please check the first few lines of the include file for "; UDF Version ...: 0.x.0"

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

Version 0.6.0 is the most current version.

What I don't get is why a non existing template doesn't raise an error at your place. I get @error = 6 which is fine if the template does not exist.

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

Got it. There is a bug in the flow of your script. Please replace

$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:\test\OutSwitch.au3.msg")
    If @error Then MsgBox(16, $sTitle, "Error returned by _OL_ItemCreate: " & @error & ", @extended: " & @extended)
Endif
with
$aFolder = _OL_FolderAccess($oOutlook, "*\Shared Folder")
If @error Then
    MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended)
Else
    _OL_ItemCreate($oOutlook, $olMailItem, $aFolder[1], "D:\test\OutSwitch.au3.msg")
    If @error Then MsgBox(16, $sTitle, "Error returned by _OL_ItemCreate: " & @error & ", @extended: " & @extended)
EndIf

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

Glad the problem could be solved! :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

Hi water,

one quick question. I'm trying to use _OL_FolderAccess on the "Test Shared" folder that belong to Christ Bow Mailbox which has been shared to me but I'm getting either error 1($iOL_FolderType is missing or not a number) or error 4(Specified folder could not be found).

$aFolder = _OL_FolderAccess($oOutlook, "Mailbox - Christ BowTest Shared")
If @error Then MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended)

Posted Image

I have try using FolderTree and FolderGet code shown below to help me retrieve the folder path but I can't seem to find the folder path for it. All I get is folder path for David Hoo mailbox.

$aResult = _OL_FolderTree($oOutlook)
_ArrayDisplay($aResult, "Folder Result")

Do I have to select or set Christ Bow Mailbox first before I can access his "Test Shared" folder?

Edited by lolipop
Link to comment
Share on other sites

Please give this code a try:

$aFolder = _OL_FolderAccess($oOutlook, "Mailbox - Christ BowTest Shared")
If @error Then MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended)

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 see the problem! When you specify "\\" then the name of the user you want to access has to follow (like you enter in the recipient field if you want to send him an email). _OL_FolderAccess resolves the user and accesses any sepcified subfolder. You specified the whole name of the mailbox. So this should work too:

Does this work for you:

$aFolder = _OL_FolderAccess($oOutlook, "\\Christ Bow\Test Shared", $olFolderInbox)
If @error Then MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended)

Maybe I need to enhance the docu ;)

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 remember trying that before and it didn't work. The difference is I never specific the folder type enumeration. I'm not wif my pc now so need to wait til Monday before I can try that out. Will post the outcome ASAP. Thanks. ;)

Link to comment
Share on other sites

I'm on vacation next week so I won't respond till the 16th.

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 sure I will. I will stay for a few days in Vienna (Austria) and enjoy Apfelstrudel and Sachertorte ;)

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 see the problem! When you specify "" then the name of the user you want to access has to follow (like you enter in the recipient field if you want to send him an email). _OL_FolderAccess resolves the user and accesses any sepcified subfolder. You specified the whole name of the mailbox. So this should work too:

Does this work for you:

$aFolder = _OL_FolderAccess($oOutlook, "Christ BowTest Shared", $olFolderInbox)
If @error Then MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended)

Maybe I need to enhance the docu ;)

Just to report, this doesn't work. I've got error stating "Variable used without being declared"
Link to comment
Share on other sites

Which variable?

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

#include <OutlookEx.au3>
ShellExecute("Outlook", "/profile Outlook", "", "", @SW_HIDE)
If @error Then Exit MsgBox(16, $sTitle, "Error returned by ShellExecute: " & @error & ", @extended: " & @extended)
$oOutlook = _OL_Open()
If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_Open: " & @error & ", @extended: " & @extended)
$aFolder = _OL_FolderAccess($oOutlook, "Christ BowTest Shared", $olFolderInbox)
If @error Then
    MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended)
Else
    $aItems2 = _OL_ItemFind($oOutlook, $aFolder[1], $olDocument, "", "Subject", "Test Share", "EntryID")
    If @error Then
        MsgBox(16, $sTitle, "Error returned by _OL_ItemFind: " & @error & ", @extended: " & @extended)
    Else
        If $aItems2[0][0] = 0 Then
            _OL_ItemCreate($oOutlook, $olMailItem, $aFolder[1], @UserProfileDir & "Desktoptestmsg.msg")
   If @error Then MsgBox(16, $sTitle, "Error returned by _OL_ItemCreate: " & @error & ", @extended: " & @extended)
        Else
   _OL_ItemDelete($oOutlook, $aItems2[1][0], Default)
   If @error Then MsgBox(16, $sTitle, "Error returned by _OL_ItemDelete: " & @error & ", @extended: " & @extended)
   _OL_ItemCreate($oOutlook, $olMailItem, $aFolder[1], @UserProfileDir & "Desktoptestmsg.msg")
   If @error Then MsgBox(16, $sTitle, "Error returned by _OL_ItemCreate: " & @error & ", @extended: " & @extended)
  EndIf
 EndIf
EndIf

hmm..I'm too sure either...

The autoit output windows wrote is

C:Documents and SettingsusernameDesktoptest.au3 (8) : ==> Variable used without being declared.:

MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended)

MsgBox(16, ^ERROR

I have try removing the affected line "MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended)

". The script will run without error but the MSG file doesn't get save into the mention folder.

Anyway just to clarify again in case you get the wrong idea, the "Mailbox - Christ BowTest Shared" works fine. Only the "Christ BowTest Shared" doesn't work. ;)

Hey, thought you're having your holidays? Go enjoy yourself man.

Link to comment
Share on other sites

Variable $sTitle is simply used to set the window title of the MsgBox. Add

Global $sTitle = "<Here goes your title>"
to the top of your script and the error messages should be gone.

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...