Opening Outlook with attachment

G

Guest

Hi all,
I am trying to open outlook express along with an attachment.
I have added a reference to the Microsoft outlook Library
I am using the following lines of code.
=============================
Outlook.Application OutApp = new Outlook.Application();
Outlook.OlItemType olItem = new Outlook.OlItemType();
Outlook.MailItem OutMail = (Outlook.MailItem)OutApp.CreateItem(olItem);
OutMail.To = ToAddress;
//OutMail.SenderName = FromAddress;
OutMail.Subject= Subject;
//OutMail.Attachments.Add(Filename,);
OutMail.Body = Body;
OutMail.Display(OutApp);
=============================

While compiling it doesnt give any error. However when I run the code it fails at the first line where I am trying to create an object of Outlook Application type
The error says " Acess is denied"

When I try to open outlook using mailto: it opens fine, but I am not able to attach a file to it at the runtime.
Any help on this will be highly appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top