Solved

Outlook Exception office interop

Posted on 2010-11-12
4
1,370 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
ID: 34122931
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
ID: 34123480
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
ID: 34123556
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
ID: 41452533
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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
calendar sharing only working in OWA But not in outlook -in Exchange Server 2010  environment 2 24
Outlook 2010 error message 6 40
IE, OUTLOOK 3 21
abstract class C# 1 31
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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: …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

840 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