Saving Message Object

G

Guest

Hi,
I am trying to save Inbox selected message in C:
I have used following code

string SavedMessage = "C:\\AIA\\Message\\";
string strSaveName = "Test.msg";
Outlook._Application olApp = new Outlook.ApplicationClass();
Outlook._NameSpace olNs = olApp.GetNamespace("MAPI");Outlook.MAPIFolder
oContacts = olApp.ActiveExplorer().CurrentFolder;
Object selObject = olApp.ActiveExplorer().Selection[1];
FileSystemObject fso = new Scripting.FileSystemObjectClass();
//selObject.SaveAs strFolderPath & strSaveName, olMSG

But I can't find SaveAs option in selObject property. What I am missing here.

Thanks
Kannan
 
G

Guest

Hi,
I have changed this below code as follows

string SavedMessage = "C:\\AIA\\Message\\";
string strSaveName = "Test.msg";
Outlook._Application olApp = new Outlook.ApplicationClass();
Outlook._NameSpace olNs = olApp.GetNamespace("MAPI");
Outlook.MAPIFolder oContacts = olApp.ActiveExplorer().CurrentFolder;
Outlook.MailItem selObject =
(Outlook.MailItem)olApp.ActiveExplorer().Selection[1];
MessageBox.Show(selObject.Subject);
//selObject.SaveAs("C:\\","Message.msg");

But when I try to call SaveAs method, it asked for one more parameter called
object Type (ie selObject.SaveAs(Path,Type)). What value I have to pass it
for Type parameter.

Please help...

thanks
 
W

Willy Denoyette [MVP]

| Hi,
| I am trying to save Inbox selected message in C:
| I have used following code
|
| string SavedMessage = "C:\\AIA\\Message\\";
| string strSaveName = "Test.msg";
| Outlook._Application olApp = new Outlook.ApplicationClass();
| Outlook._NameSpace olNs = olApp.GetNamespace("MAPI");Outlook.MAPIFolder
| oContacts = olApp.ActiveExplorer().CurrentFolder;
| Object selObject = olApp.ActiveExplorer().Selection[1];
| FileSystemObject fso = new Scripting.FileSystemObjectClass();
| //selObject.SaveAs strFolderPath & strSaveName, olMSG
|
| But I can't find SaveAs option in selObject property. What I am missing
here.
|
| Thanks
| Kannan

Sorry, I don't want to sound harsh, but you are missing a lot.
First, you need to understand the CLR's object model, so that you know that
the CLR Object class doesn't implement a SaveAs method (I hope you
understand that Object in .NET is not the same as Object in VBA).
Second, you must understand the outlook object model, so you need to start
by reading this: http://msdn2.microsoft.com/en-us/library/ms268893.aspx and
this:
http://msdn.microsoft.com/library/d...vbaol11/html/OutlookVBAWelcome_HV01136199.asp.

You must also understand that .NET comes with a rich class library, so there
is no need to use scripting objects like FileSystemObject, start by getting
used to the FCL. And I would suggest you to start with VB.NET instead of C#,
the language is better suited for this kind of tasks, especially when you
come from a scripting environment like VBA and/or VBScript.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top