 |
|
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
|
 |
Hello
With the help of coffee and guesswork I've managed to use COM and Interop to open an Outlook .msg file and extract content from it. I have Outlook 2007 installed and I'm using Microsoft.Office.Interop.Outlook PIA runtime version 2.0.50727 (Version 14.0.0.0)
I'm using .NET 4 in a WPF application.
My problem is that my code starts an Outlook process but does not close it down afterwards. If I am already running Outlook, my code seems to attach to that process rather than start another one and if outlook is already running, my app.Quit() message closes the existing Outlook application (not the process.)
My question is am I going about this in the wrong way? I've read lots of posts about using Outlook but nothing that describes with authority how I should cleanly open, interrogate and close an outlook message.
Here's the code:
public override void ViewContent(string strFilePath)
{
base.ViewContent(strFilePath);
Microsoft.Office.Interop.Outlook.Application app = null;
Microsoft.Office.Interop.Outlook.NameSpace session = null;
Microsoft.Office.Interop.Outlook.MailItem item = null;
try
{
app = new Microsoft.Office.Interop.Outlook.Application();
session = app.Session;
item = session.OpenSharedItem(strFilePath) as Microsoft.Office.Interop.Outlook.MailItem;
if(item != null)
{
Subject = item.Subject;
From = item.SenderName;
if(string.IsNullOrEmpty(item.SenderEmailAddress) == false)
From += "{" + item.SenderEmailAddress + "}";
MessageText = item.Body;
item.Unload += new ItemEvents_10_UnloadEventHandler(item_Unload);
item.Close(OlInspectorClose.olDiscard);
}
app.Quit();
}
catch(Exception)
{
}
finally
{
if(item != null)
System.Runtime.InteropServices.Marshal.ReleaseComObject(item);
if(session != null)
System.Runtime.InteropServices.Marshal.ReleaseComObject(session);
if(app != null)
System.Runtime.InteropServices.Marshal.ReleaseComObject(app);
item = null;
session = null;
app = null;
}
}
Is this the right way to use COM and Interop? Does anyone have any pointers for me or a guide showing best practices? I'm new to COM so if anyone thinks my code is going to leak or use up handles or some other horror please let me know.
Thanks all,
Keith
|
|
|
|
 |
|
 |
So, I had asked the question in the subject itself: Is COM an 'outdated' technology?
If it is, what are the technologies that replace COM? And how?
If it is not, why such an old technology is still there? (I understand the basic design of COM and I understand why it was needed back then.)
I am hoping to see a discussion emerging about this, in the hope that I will be able to learn a lot.
|
|
|
|
 |
|
 |
krumia wrote: I am hoping to see a discussion emerging about this,
This forum is not the place for discussions, it's for technical questions; try the Lounge.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
 |
|
 |
I thought of posting this in the lounge, but all the same this is where most the COM experts gather, I suppose.
I have asked what I felt as a technical question anyway: Is COM an 'outdated' technology?
having asked the technical question in the technical forum, I don't think 'hoping to see a discussion' is a sin. After all, the boundary between question-answer session and discussion is unclear.
Anyway, I will re-post this in the lounge. Thanks for the hint.
|
|
|
|
 |
|
 |
krumia wrote: I have asked what I felt as a technical question anyway: Is COM an 'outdated' technology?
No, you have asked a philosophical question, there is nothing technical about it. You are asking people to give their opinions on something; opinions that will vary widely based on their own assumptions and possibly even prejudices.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
 |
|
 |
Richard MacCutchan wrote: This forum is not the place for discussions
err, umm "Home Articles Quick Answers Discussions Learning Zones Features Help! The Lounge
|
|
|
|
 |
|
 |
OK, let's count the number of people who responded to this call for a discussion here.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
 |
|
 |
It amazes me how many people attempt to use redirection instead of acknowledging that someone elses point was valid. At this point in time, the tab above for this forum is titled "Discussions". You were wrong. Just admit it.
|
|
|
|
 |
|
 |
As I said, count how many people actually responded to the request for a discussion. Try answering the question; but first make sure you read How-to-get-an-answer-to-your-question[^].
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
 |