Solved

Outlook Exception office interop

Posted on 2010-11-12
4
1,355 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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 …

773 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