Solved

Outlook Exception office interop

Posted on 2010-11-12
4
1,328 Views
Last Modified: 2016-02-06
Hello
I have some code that lauches an email (Microsoft Outlook) and add the emailadress, subject, attachment and body


As soon as I the code hits Outlook.Application outlookApp = new Outlook.Application();
it throws an exception only if Microsoft outlook was already open.

If outlook wasn't open on the user machine all works welol.
Any idean how I can resolve this?I know I can ask the user to close the app, but that is ionconvenient

Thanks
Outlook.Application outlookApp = new Outlook.Application();



Outlook.MailItem message = (Outlook.MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);



message.Subject = “subject “

message.Recipients.Add(“someone@email.com”);



message.Body = “”;



int attachmentLocation = 1;





message.Attachments.Add(“” + ConfigurationSettings.AppSettings["Atachments"] + “Course Schedules for “ + lblProviderName.Text + “.xls”, Outlook.OlAttachmentType.olByValue,



attachmentLocation, “Course Schedules for “ + lblProviderName.Text + “.xls”);



message.Display(true);

Open in new window

0
Comment
Question by:xav056
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
Gary Davis earned 500 total points
Comment Utility
This may help. It discusses checking if Outlook is running and if so, use GetObject() to get to it.

http://www.eggheadcafe.com/software/aspnet/35993966/handling-applicationquit-event.aspx

Gary Davis
0
 
LVL 9

Author Comment

by:xav056
Comment Utility
looks promising but I am getting an exception
Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))
as soon as i call GetActiveObject("Outlook.Application")

any ideas?

thanks
0
 
LVL 18

Expert Comment

by:Gary Davis
Comment Utility
Try this article:

"GetObject or GetActiveObject cannot find a running Office application"

http://support.microsoft.com/kb/238610

Or google your error 0x800401E3.

Gary
0
 
LVL 10

Expert Comment

by:cdebel
Comment Utility
I know this question was asked long time ago, but the only thing i see in KB 238610 is a partial answer.

I would add: Never underestimate your customer.  They may very well run an Evaluation Version of Outlook, expired, and for some reason they have managed to "make it work anyway"... but still, you will get this error (0x800401E3).  

Just found out... Thanks customer!  Lost 500$ trying to solve a problem that would have cost 110$ if the customer was not so cheap.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now