Sign in to follow this  
Followers 0
pickypiglet

Outlook EX UDF - Export to .csv using _OL_ItemExport()

4 posts in this topic

Hi There,

Tried to use _OL_ItemExport function to get items from my calendar. It returns a .csv.

However, when I try to export the Body/Description it puts on a separate line even though it is the same item. The reason is because the Body of the Calendar item has <enter>. So one calender item is now showing as several lines in my .csv file.

How can I keep it on the same line or change the row delimiter? I could only find the field delimiter option for this function.

Here's my code snippet:

$aData= _OL_ItemFind($oOutlook, "*\Calendar", $olAppointment, "[start]>='"&$start&"'", "", "", "Subject,Start,End,Body", "", 2)

If @error <> 0 Then Exit MsgBox(16, "", "Error getting calendar from folder '*\Calendar'. @error = " & @error & ", @extended = " & @extended)

Global $iResult = _OL_ItemExport($filename, "~", "", 1, "Subject,Start,End,Body", $aData)

If @error <> 0 Then Exit MsgBox(16, "", "Error exporting Calendar to file. @error = " & @error & ", @extended = " & @extended)

MsgBox(64, "", $iResult & " Calendar successfully exported to file")

Thx in advance!!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$aData= _OL_ItemFind($oOutlook, "*Calendar", $olAppointment, "[Start]>='"&$start&"'", "", "", "Subject,Start,End,Body", "", 2)
; ... here replace all @CRLF to "space" in column Body for all rows of array $aData ...
Global $iResult = _OL_ItemExport($filename, "~", "", 1, "Subject,Start,End,Body", $aData)

Edited by Zedna

Share this post


Link to post
Share on other sites

I am trying to modify this sample script to extract subject to a csv file for emails in a specific folder. I have an automated process that sends 'fax emails', for lack of a better term, to a service that turns the emails into faxes and deals with that end of the process. A number of these 'faxes' bounce every day and I would like to examine our email history and determine if there is any pattern to the bounces by exporting the subject lines...

I have started with a sample script and am trying to adapt it to the purpose, but I am having some trouble.

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

; *****************************************************************************
; Create test environment
; *****************************************************************************
Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a 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)

; *****************************************************************************
; Example 1
; Export all contacts from the test folder to c:\temp\_OL_ItemExport.csv
; *****************************************************************************
;"[From]>='MetroFax'"
Global $aData = _OL_ItemFind($oOutlook, "*\TTL Reports Response", $olMail, "", "", "", "From,Subject")
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemExport Example Script", "Error getting mail from folder '*\TTL Reports Response'. @error = " & @error & ", @extended = " & @extended)
Global $iResult = _OL_ItemExport("C:\temp\_OL_ItemExport.csv", "", "", 1, "Subject", $aData)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemExport Example Script", "Error exporting contacts to file 'C:\temp\_OL_ItemExport.csv'. @error = " & @error & ", @extended = " & @extended)
MsgBox(64, "OutlookEX UDF: _OL_ItemExport Example Script", $iResult & " contact(s) successfully exported to file 'C:\temp\_OL_ItemExport.csv'.")

_OL_Close($oOutlook)

I get the following error when I run ...

post-76961-0-85213400-1365623085_thumb.j

Any assistance is appreciated...


And the sign said 'Long Hairded Creepy People Need Not Apply' ... So I stuffed my hair up under my hat and I went in to ask him why?

Share this post


Link to post
Share on other sites

@error = 1xx means: "Error checking $sReturnProperties as returned by __OL_CheckProperties."

Property "From" does not exist. It is either "SenderEmailAddress" or "SenderName"


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0