Monday, October 6, 2008

Copy and Paste My Scripts

If anyone has any issues copying my scripts, as in everything pasting on one line, just do the following:

Paste into wordpad or word, not notepad or autoitscript.

Then save the file as an .au3.

You should then be able to open it in notepad or the Scite editor properly.

Outlook CSV Import

OutlookCSVImport - Import a CSV file into Outlook.
Match up the necessary fields and modify the script if needed. Remove or add any additional fields.

Based on http://tinyurl.com/4uce9k
Download Microsoft Outlook VBA Language Reference for other properties that were not listed here.

There were 4 properties in an export i originally created this for that do not have a corresponding field in Outlook. I added them as part of the Body field (notes field).

The script will add the excel file into the default Outlook Contacts folder. Something to keep in mind while testing :)

Sort the Excel file by the FileAs field. My export came from http://www.codetwo.com/ Outlook export tool.
The client this was made for had custom fields that Outlook would not export out. The third party tool did a great job.
Renamed a few of the custom contact fields to what was needed and set the rest to be part of notes.
Outlook's natural import/export function with the "Map Custom Fields" does not work correctly. Quite a few existing Outlook fields,
do not export or import, even while it creates a csv column entry for the field (nickname is one example).
Called Microsoft on this issue. Will see what answer they come up with.

If the program crashes at any point look for the contact that crashed it, i had a field with a #name? in it that caused a crash.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=OutlookCSVImport.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs
    OutlookCSVImport - Import a CSV file into Outlook.
    Match up the necessary fields and modify the script if needed. Remove or add any additional fields.
    
    Based on http://tinyurl.com/4uce9k
    Download Microsoft Outlook VBA Language Reference for other properties that were not listed here.
    
    There were 4 properties in an export i originally created this for that do not have a corresponding field in Outlook.
    I added them as part of the Body field (notes field).
    
    The script will add the excel file into the default Outlook Contacts folder. Something to keep in mind while testing :)
    
    Sort the Excel file by the FileAs field. My export came from http://www.codetwo.com/ Outlook export tool.
    The client this was made for had custom fields that Outlook would not export out. The third party tool did a great job.
    Renamed a few of the custom contact fields to what was needed and set the rest to be part of notes.
    Outlook's natural import/export function with the "Map Custom Fields" does not work correctly. Quite a few existing Outlook fields,
    do not export or import, even while it creates a csv column entry for the field (nickname is one example).
    Called Microsoft on this issue. Will see what answer they come up with.
    Visit http://nyitsupport.blogspot.com for an update.
    
    If the program crashes at any point look for the contact that crashed it, i had a field with a #name? in it that caused a crash.
        
    Alex Belenkiy 
    ab@nyitsupport.com
    10/06/08
    
#ce
 
 
Const $olContactItem = 2
 
$objOutlook = ObjCreate("Outlook.Application")
 
$objExcel = ObjCreate("Excel.Application")
$ExcelFile = FileOpenDialog("Please choose an Excel file to open", @WorkingDir, "Excel Files (*.xls;*.xlsx;*.csv)",1)
$objWorkbook = $objExcel.Workbooks.Open($ExcelFile)
 
$x = 2
 
Do 
    $objContact = $objOutlook.CreateItem($olContactItem)
    ;---------------------------------------------------------------------------------------------
    $objContact.AssistantName = $objExcel.Cells($x,2).Value
    $objContact.AssistantTelephoneNumber =     $objExcel.Cells($x,3).Value
    $objContact.Body = "Assistant's Email: " & $objExcel.Cells($x,1).Value & @CRLF & "Contact Type: " & $objExcel.Cells($x,13).Value & @CRLF & "Contacts: " & $objExcel.Cells($x,14).Value & @CRLF & "Cross Street: " & $objExcel.Cells($x,15).Value & @CRLF & "Private Number: " & $objExcel.Cells($x,49).Value & @CRLF & @CRLF & @CRLF & $objExcel.Cells($x,4).Value
    $objContact.BusinessAddress = $objExcel.Cells($x,5).Value
    $objContact.BusinessAddressCity = $objExcel.Cells($x,6).Value
    $objContact.BusinessAddressPostalCode = $objExcel.Cells($x,7).Value
    $objContact.BusinessAddressState = $objExcel.Cells($x,8).Value
    $objContact.BusinessAddressStreet = $objExcel.Cells($x,9).Value
    $objContact.Categories = $objExcel.Cells($x,10).Value
    $objContact.CompanyName = $objExcel.Cells($x,11).Value
    $objContact.PrimaryTelephoneNumber = $objExcel.Cells($x,12).Value
    $objContact.Email1Address = $objExcel.Cells($x,16).Value
    $objContact.Email1DisplayName = $objExcel.Cells($x,17).Value
    $objContact.Email2Address = $objExcel.Cells($x,18).Value
    $objContact.Email2DisplayName = $objExcel.Cells($x,19).Value
    $objContact.Email3Address = $objExcel.Cells($x,20).Value
    $objContact.Email3DisplayName = $objExcel.Cells($x,21).Value
    $objContact.BusinessFaxNumber = $objExcel.Cells($x,22).Value
    $objContact.HomeFaxNumber = $objExcel.Cells($x,23).Value
    $objContact.OtherFaxNumber = $objExcel.Cells($x,24).Value
    $objContact.FileAs = $objExcel.Cells($x,25).Value
    $objContact.FirstName = $objExcel.Cells($x,26).Value
    $objContact.FullName =     $objExcel.Cells($x,27).Value
    $objContact.HomeAddress = $objExcel.Cells($x,28).Value
    $objContact.HomeAddressCity = $objExcel.Cells($x,29).Value
    $objContact.HomeAddressPostalCode = $objExcel.Cells($x,30).Value
    $objContact.HomeAddressState = $objExcel.Cells($x,31).Value
    $objContact.HomeAddressStreet = $objExcel.Cells($x,32).Value
    $objContact.JobTitle = $objExcel.Cells($x,33).Value
    $objContact.LastName = $objExcel.Cells($x,34).Value
    $objContact.MiddleName = $objExcel.Cells($x,35).Value
    $objContact.Nickname = $objExcel.Cells($x,36).Value
    $objContact.OtherAddress = $objExcel.Cells($x,37).Value
    $objContact.OtherAddressCity = $objExcel.Cells($x,38).Value
    $objContact.OtherAddressPostalCode = $objExcel.Cells($x,39).Value
    $objContact.OtherAddressState = $objExcel.Cells($x,40).Value
    $objContact.OtherAddressStreet = $objExcel.Cells($x,41).Value
    $objContact.BusinessTelephoneNumber = $objExcel.Cells($x,42).Value
    $objContact.Business2TelephoneNumber = $objExcel.Cells($x,43).Value
    $objContact.CarTelephoneNumber = $objExcel.Cells($x,44).Value
    $objContact.CompanyMainTelephoneNumber = $objExcel.Cells($x,45).Value
    $objContact.HomeTelephoneNumber = $objExcel.Cells($x,46).Value
    $objContact.MobileTelephoneNumber = $objExcel.Cells($x,47).Value
    $objContact.OtherTelephoneNumber = $objExcel.Cells($x,48).Value
    $objContact.Spouse = $objExcel.Cells($x,50).Value
    $objContact.Subject = $objExcel.Cells($x,51).Value
    $objContact.Title = $objExcel.Cells($x,52).Value
    $objContact.WebPage = $objExcel.Cells($x,53).Value
    ;---------------------------------------------------------------------------------------------
    $objContact.Save
    $x = $x + 1
Until $objExcel.Cells($x,25).Value = ""
$objExcel.Quit