Exception when add attachment programmatically in vc++


Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Interoperability RSS
Next:  Outlook 2007  
Author Message
Tahir Quraishi
External


Since: Aug 09, 2007
Posts: 1



PostPosted: Thu Aug 09, 2007 6:28 am    Post subject: Exception when add attachment programmatically in vc++
Archived from groups: microsoft>public>outlook>interop (more info?)

Hi,

I am writing a vc dll and I want to automate Outlook. I can create a new
mail item and send email no problem. The exception happens when I try to add
attachment to the mail item.

I am calling my dll from Java applet using JNI. Any suggestion why I am
getting exception when I try to add attachment and how to fix this problem.
Here is my code for adding attachment and send mail:

_NameSpace olNs(olApp.GetNamespace("MAPI"));
COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
olNs.Logon(covOptional, covOptional, covOptional, covOptional);
_MailItem olMail(olApp.CreateItem(0));
olMail.SetTo("friend@aaaa.com");
olMail.SetSubject("Email subject");
Attachments atts = olMail.GetAttachments();
olMail.SetBody("Message text");

COleVariant covFilePath("C:\\email.txt");
atts.Add(covFilePath, covOptional, covOptional,covOptional); // fails here

olMail.Send();

Thanks
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Interoperability All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum