Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Outlook Exception office interop

Posted on 2010-11-12
4
Medium Priority
?
1,494 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 2000 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:Christian de Bellefeuille
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

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

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

This article will help to fix the below errors for MS Exchange Server 2016 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
Today as you open your Outlook, you witness an error message: “Outlook is using an old copy of your Outlook Data File…”. Probably, Outlook is accessing an old OST file.
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

804 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