How to archive mails using VSTO 3.0

  • Thread starter Pradeep Yamujala
  • Start date
P

Pradeep Yamujala

Hi all,

I am developing a outlook plugin for one organization. In one of the
requirment i have to archive a mail, and retrive back when ever necessory. I
need to do searching also.

But unfortunatly i am not getting goon info about how to?. Please
help me how to perform archiving function using C# in VSTO.

Thanks in advance.
 
K

Ken Slovak - [MVP - Outlook]

Archive what email? How is it selected or identified? Where is it located?
Archive to where? Provide actual details of what you want so people don't
have to try to read your mind over the Internet, that doesn't work very
well.
 
P

Pradeep Yamujala

Hi Ken,

In my client environment, they are using exchange server. In that
they created few shared inboxes. All the users has their own dedicated mail
accounts. These shared inboxes attached to the dedicated mail accounts so
that when they login able to retrive these inboxes.

As per my knowledge the archival file might be in the exchange
server only. What my plugin must do is, what ever mail they selected must go
in archives oncce he clicked on "Archive" button. Also I must search the
mails in archives also, if user wants he can retrive the same.

At this point i want to know how to pweform this archival
operation using VSTO 3.0 and C#. And also how to search in the archive folder.

I hope this explains my doubt. Please help me to solve this problem.

Thanks
Pradeep Yamujala
 
K

Ken Slovak - [MVP - Outlook]

To get a shared Inbox folder you would use
NameSpace.GetSharedDefaultFolder(). That method takes a Recipient object and
folder type as arguments. The Recipient is the owner of the mailbox, the
type would be a member of the OlDefaultFolders enum, in this case
olFolderInbox.

A selected item in the current folder view is
Application.ActiveExplorer.Selection[1]. You can test for
Application.ActiveExplorer.Selection.Count to see how many items are
selected. You can test for that item's Class property to make sure it's a
mail item. That would be OlObjectClass.olMail.

You have to explain what you mean by "As per my knowledge the archival file
might be in the exchange
server only.", that could be anywhere. Assuming you mean the archive folder
is in the Exchange public folders store just below the All Public Folders
location then you'd use something like this:

// ns is an instantiated NameSpace object
Outlook.MAPIFolder folder =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olPublicFoldersAllPublicFolders).Folders["Archive"];

You would then use the Move() function for the item to be archived to move
it to that archive folder.

You can then store the EntryID of the moved item for future reference, along
with the StoreID of the public folder to be able to retrieve it later using
NameSpace.GetItemFromID(). Or you can search the Items collection of the
archive folder using any property you want using either the Find() or
Restrict() methods of the Items collection, or you can do a brute force
search in the folder to match whatever property you are searching on.

For future reference you should always provide as much information as
possible, including the version or versions of Outlook you want to support.
 

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