The Outlook2CRM Addin Client API provides many useful methods for building custom actions for Outlook2CRM. Several of these methods allow you to easily work with files attached to the current e-mail as well. These included methods will do all the heavy lifting for you and also ensure that you don't get any of the Outlook security prompts.
Let's say, for example, you'd like to save all the files attached to the e-mail to some location on the computer. You can do this with the Addin_SaveAttachments function. This function takes a parameter of a folder location to save the files to and returns a serialized .NET ArrayList containing strings of the full file name & path for each of the saved files. This allows you to do the following:
Dim filelist
Dim file
filelist = Addin_SaveAttachments("C:\My Files")
For Each file in filelist
' The "file" variable now contains a string
' of the full file name and path
MsgBox file
Next
This code saves the files, and any inline embedded images in the e-mail to the C:\My Files folder. It returns the ArrayList to allow you to work with the saved files as well and do something with them. Don't forget to use the Outlook2CRM API in your custom actions you must include the script "Outlook2CRM:Outlook2CRM Addin Client API".
Some other file related methods available in the API are as follows:
- Addin_AttachmentList - Returns a serialized .NET
ArrayList containing the names of all files attached to the e-mail.
- Addin_HasAttachments
- Returns a boolean indicating whether the current e-mail has attached
files or not
- Addin_AttachmentCount - Returns an integer
count of all the number of files attached to the current e-mail
- Addin_SaveAttachments(Location)
- The one I mentioned already. You pass to it a folder location and it
will save the files there and return a serialized ArrayList containing
strings of the full path & name of the files saved
- Addin_SaveAttachmentsToContact
- This will save all files attached to the e-mail as attachment entries
on the matched contact record and queue the files to be synchronized
- Similar
to the Addin_SaveAttachmentsToContact, there are also the following methods which will save the files, create the SalesLogix attachments and queue the files to be synchronized:
- Addin_SaveAttachmentsToTicket(TicketID)
- Addin_SaveAttachmentsToOpportunity(OpportunityID)
- Addin_SaveAttachmentsToLead(LeadID)