Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Interop / March 2005

Tip: Looking for answers? Try searching our database.

Programming Outlook 2003 with C#...folders problems

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paulos - 23 Mar 2005 22:11 GMT
I am trying to make improvements to an app I wrote a while back in C#.

What I want to do is to move an email message from the Inbox to another
folder within the inbox that I have created called 'JS Archive'.

NameSpace objOLNS = objOL.GetNamespace("MAPI");
            MAPIFolder objInbox =
objOLNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);

The above code gives me access to the inbox but I cannot figure out how
I get access to folders that I create (i.e. not one of the default folders)

Anyone out there know how this is done?

Secondly, anyone know how to move an email from one folder to another.

Cheers

Paul BJ
Helmut Obertanner - 23 Mar 2005 22:19 GMT
Hello Paulos,

MAPIFolder otherFolder = objInbox.Folders["JS Archive"];

or first get ParentFolder

MAPIFolder parentFolder = objInbox.Parent // the Store
MAPIFolder otherFolder = parentFolder .Folders["JS Archive"];

that should do the trick.

Signature

regards

Helmut Obertanner
Technical Consultant

Softwaredevelopment
DATALOG Software AG | Zschokkestr. 36 | D-80687 Munich
web: www.datalog.de

... and IT works!

>I am trying to make improvements to an app I wrote a while back in C#.
>
[quoted text clipped - 15 lines]
>
> Paul BJ
Paulos - 23 Mar 2005 22:27 GMT
> Hello Paulos,
>
[quoted text clipped - 6 lines]
>
> that should do the trick.

Damn, Damn,  DAMN!

Thats the second time I have been held up for the same reason...trying
to use ()s when in C# I need []s.

Clearly I have been programming in VB and VBA for too long and I have
been neglecting my C based languages!

Thanks!

Paul BJ
Helmut Obertanner - 23 Mar 2005 22:30 GMT
Hello Paulos,
Second question:

MAPIFolder objInbox =  objOLNS.GetDefaultFolder
olDefaultFolders.olFolderInbox);
MAPIFolder otherFolder = objInbox.Folders["JS Archive"];

foreach (object item in objInbox.Items)
{
   if (item == MailItem)
   {
       MailItem mailItem = (MailItem) item;
       if (mailItem.Subject.StartsWith("JS"))
       {
           mailItem.Move(otherFolder);
       }
       Marshal.ReleaseComObject(mailItem);
   }

}

       Marshal.ReleaseComObject(otherFolder );
       Marshal.ReleaseComObject(objInbox);
GC.Collect();

Signature

Freundliche Gr??e / regards

Helmut Obertanner
Technical Consultant

Softwaredevelopment
DATALOG Software AG | Zschokkestr. 36 | D-80687 Munich
web: www.datalog.de

... and IT works!

>I am trying to make improvements to an app I wrote a while back in C#.
>
[quoted text clipped - 15 lines]
>
> Paul BJ
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.