cancel
Showing results for 
Search instead for 
Did you mean: 

outlook question

former_member203861
Participant
0 Kudos

Hi all ,

I want to save into a table an outlook message as file ( the file's path) , how do i do that quick and easy for the user ?

(my table saves all kind of files ,  path + file name and opens it with the according program )

working with pb 12.5 classic with sqlanywhere 11 , MsSql.

Thanks

Moshe

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

There is a SaveAs method you can use when interacting with Outlook via OLE.

SaveAs Method [Outlook 2007 Developer Reference]

I have an example that uses OLE to interact with Outlook. It doesn't do a SaveAs but it does have an example of using the Delete method.

Topwiz Software - Outlook

former_member203861
Participant
0 Kudos

Hi Roland ,

I took your code from Topwiz , and it works ofcourse ( as you well know ) ,

But , I am getting an Error trying to SaveAs(Is_FilePathName)

The error is : "Error getting external object ....." .

I did read the code in the link but it does not work for me .

Answers (2)

Answers (2)

Former Member
0 Kudos

To use the SaveAs, you first need the following constants:

// OlSaveAsType Enumeration

Constant Integer olDoc = 4

Constant Integer olHTML = 5

Constant Integer olICal = 8

Constant Integer olMHTML = 10

Constant Integer olMSG = 3

Constant Integer olMSGUnicode = 9

Constant Integer olRTF = 1

Constant Integer olTemplate = 2

Constant Integer olTXT = 0

Constant Integer olVCal = 7

Constant Integer olVCard = 6

The function call would look like this:

oleMailItem.SaveAs(ls_filename, olMSG)

Former Member
0 Kudos

I reworked my example and included a SaveAs button and a Print button.

It now connects to Outlook in the application open event and disconnects in the application close event. Before it connected/disconnect in each button.

Topwiz Software - Outlook

former_member203861
Participant
0 Kudos

Hi Roland ,

Big thanks for all the help ,

All works fine with office 2003 but with office 2010 when trying to open the msg file which was saved before , I am getting an error message from the outlook ,

Did you try it with 2010 ?

Regards

Moshe

Former Member
0 Kudos

I tried Roland's code with MS Outlook 2010 and all is good. I can save and open the saved messages with no error. What error message are you getting?

former_member203861
Participant
0 Kudos

Hi Neil ,

I works with the Hebrew office so I don't know how to translate exactly to english

its something like : " The command line's argument is wrong. check the convertor you are using"

does it make sense to you ?

Former Member
0 Kudos

If you mean saving the message as a blob into the database, you will need to do as Roland suggested and save the email to disk first and then stream the file in as a blob to store it into the database.

Something like this to read the file from the disk

li_fnum = FileOpen(as_filename,  StreamMode!)

if li_fnum < 0 then

  Messagebox('Error opening file in Stream Mode', 'File:  ' + as_filename, exclamation!)

  return li_fnum

end if

ll_bytes = FileReadEx(li_fnum, ablb_fileimage)

FileClose(li_fnum)

To view the file, you will need to do the reverse before you can launch the MSG file to view the message.

former_member203861
Participant
0 Kudos

Hi Allan ,

I don't want to save it as blob , just a link to the saved msg file .

the problem is I getting an error trying saving to file the outlook message as calling to

SaveAs() method .

Thanks

Moshe

Former Member
0 Kudos

Hi Mosche,

As Roland has listed, the Mailitem SaveAs method has an additional parameter for the message type.  The second parameter is shown as optional in the MS documentation, however it's required when called via Powerbuilder's OLE interface (late binding)