PC Review


Reply
Thread Tools Rating: Thread Rating: 2 votes, 1.00 average.

C#.Net Outlook 2003 automation (programmatically) with Interop

 
 
=?Utf-8?B?cm9i?=
Guest
Posts: n/a
 
      13th Feb 2007
C#.Net Outlook 2003 automation (programmatically) with
Microsoft.Office.Interop.Outlook

Problem:
I have my outlook 2003 configured with multiple mailbox on my local machine.
I want to specify the mailbox and server (Exchange server mail box)
to connect and then save the mailitems(from Inbox or any other folder)
based on a filter to a*.msg file.
I want to achieve this using only one Interop dll if this is possible.

Tried so far:
I have tried using both Outlook 11.0 object library
(Microsoft.Office.Interop.Outlook)
and Interop.MAPI dll but have not been successful to connect to a different
mailbox and save to *.msg file using only Interop.Outlook or Interop.MAPI.

Using Microsoft.Office.Interop.Outlook:
I have been able to save the defaultfolder(Inbox) to *.msg files
but I want to change the default mailbox to a second mailbox like
username2 instead of default mailbox username1.
How do I accomplish this using automation from C#.Net using
Microsoft.Office.Interop.Outlook?

Other Workaround using Interop.MAPI dll:
I have been able to connect using the Session.Logon of the interop.MAPI dll
but the mapi dll object model does not allow the messages to be saved to
*.msg file.
Any workaround using Interop.MAPI dll?

Any ideas/suggestions are welcome.

Thanks
Rob


 
Reply With Quote
 
 
 
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      13th Feb 2007
CDO and Extended MAPI are not supported for use with .NET code or for usage
across the Interop.

You can log into a different Outlook profile that has the secondary mailbox
or you can load it as part of your profile or use
NameSpace.GetSharedDefaultFolder to get at that mailbox. If it's part of
your profile just iterate the Folders collection of NameSpace to find the
top of that store and walk it down to get to the secondary mailbox. Using
GetSharedDefaultFolder you create a Recipient object of an alias that has
permissions to log into that mailbox and specify to load the Inbox folder.

From those points you just save the items as MSG as usual.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"rob" <(E-Mail Removed)> wrote in message
news:1A961DD7-F45A-4026-9188-(E-Mail Removed)...
> C#.Net Outlook 2003 automation (programmatically) with
> Microsoft.Office.Interop.Outlook
>
> Problem:
> I have my outlook 2003 configured with multiple mailbox on my local
> machine.
> I want to specify the mailbox and server (Exchange server mail box)
> to connect and then save the mailitems(from Inbox or any other folder)
> based on a filter to a*.msg file.
> I want to achieve this using only one Interop dll if this is possible.
>
> Tried so far:
> I have tried using both Outlook 11.0 object library
> (Microsoft.Office.Interop.Outlook)
> and Interop.MAPI dll but have not been successful to connect to a
> different
> mailbox and save to *.msg file using only Interop.Outlook or Interop.MAPI.
>
> Using Microsoft.Office.Interop.Outlook:
> I have been able to save the defaultfolder(Inbox) to *.msg files
> but I want to change the default mailbox to a second mailbox like
> username2 instead of default mailbox username1.
> How do I accomplish this using automation from C#.Net using
> Microsoft.Office.Interop.Outlook?
>
> Other Workaround using Interop.MAPI dll:
> I have been able to connect using the Session.Logon of the interop.MAPI
> dll
> but the mapi dll object model does not allow the messages to be saved to
> *.msg file.
> Any workaround using Interop.MAPI dll?
>
> Any ideas/suggestions are welcome.
>
> Thanks
> Rob
>
>


 
Reply With Quote
 
=?Utf-8?B?cm9i?=
Guest
Posts: n/a
 
      13th Feb 2007
Ken,

Thanks for the suggestion.

Do you have a sample to create a recipient object that
uses GetSharedDefaultFolder in c#?

I have two mailboxes set in outlook
1) Mailbox - username1 -- default mailbox
2) Mailbox - username2

I should create a recipient object that points to Mailbox - username2
and lets assume an userid username2 and password of 'password'.

I should point to Mailbox - username2 and loop through the folders
collection to get to inbox and save the email messages to a *.msg file.

Thanks
Rob

"rob" wrote:

> C#.Net Outlook 2003 automation (programmatically) with
> Microsoft.Office.Interop.Outlook
>
> Problem:
> I have my outlook 2003 configured with multiple mailbox on my local machine.
> I want to specify the mailbox and server (Exchange server mail box)
> to connect and then save the mailitems(from Inbox or any other folder)
> based on a filter to a*.msg file.
> I want to achieve this using only one Interop dll if this is possible.
>
> Tried so far:
> I have tried using both Outlook 11.0 object library
> (Microsoft.Office.Interop.Outlook)
> and Interop.MAPI dll but have not been successful to connect to a different
> mailbox and save to *.msg file using only Interop.Outlook or Interop.MAPI.
>
> Using Microsoft.Office.Interop.Outlook:
> I have been able to save the defaultfolder(Inbox) to *.msg files
> but I want to change the default mailbox to a second mailbox like
> username2 instead of default mailbox username1.
> How do I accomplish this using automation from C#.Net using
> Microsoft.Office.Interop.Outlook?
>
> Other Workaround using Interop.MAPI dll:
> I have been able to connect using the Session.Logon of the interop.MAPI dll
> but the mapi dll object model does not allow the messages to be saved to
> *.msg file.
> Any workaround using Interop.MAPI dll?
>
> Any ideas/suggestions are welcome.
>
> Thanks
> Rob
>
>

 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      13th Feb 2007
If the email address for mailbox 2 is "(E-Mail Removed)" then it would go
something like this in C#.

// app == Outlook.Application, ns == NameSpace
Outlook.Recipient recip =
(Outlook.Recipient)ns.CreateRecipient("(E-Mail Removed)");
recip.Resolve;

Outlook.MAPIFolder folder = (Outlook.Folder)ns.GetSharedDefaultFolder(recip,
Outlook.OlDefaultFolders.olFolderInbox);

or you can get the ns.Folders collection and look for one with a caption of
"Mailbox - User 2" and from there get that Folder's Folders collection and
look for one named "Inbox".


--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"rob" <(E-Mail Removed)> wrote in message
news:B2C15D06-E349-4711-9634-(E-Mail Removed)...
> Ken,
>
> Thanks for the suggestion.
>
> Do you have a sample to create a recipient object that
> uses GetSharedDefaultFolder in c#?
>
> I have two mailboxes set in outlook
> 1) Mailbox - username1 -- default mailbox
> 2) Mailbox - username2
>
> I should create a recipient object that points to Mailbox - username2
> and lets assume an userid username2 and password of 'password'.
>
> I should point to Mailbox - username2 and loop through the folders
> collection to get to inbox and save the email messages to a *.msg file.
>
> Thanks
> Rob


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook Automation Problem using Microsoft.Office.Interop.Outlook DP Microsoft Outlook Form Programming 2 20th Oct 2010 02:21 PM
C#.Net Outlook 2003 automation (programmatically) with Office.Inte =?Utf-8?B?cm9i?= Microsoft C# .NET 1 16th Feb 2007 07:30 AM
vb.net Automation Issues - COM Interop SiJP Microsoft Dot NET 0 13th Apr 2006 03:11 PM
Interop/Automation on Webserver Marcus Microsoft ASP .NET 0 27th Aug 2004 01:22 AM
.NET MS office automation through COM interop =?Utf-8?B?VHJvbmQgQS4gUy4gQW5kZXJzZW4=?= Microsoft Dot NET Framework 2 30th Jan 2004 08:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:43 AM.