T
Tahir Quraishi
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("(e-mail address removed)");
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
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("(e-mail address removed)");
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