0
votes

I have a Outlook Add-In from which I want to access Outbox of mail item and get the first mail of outbox programmatically in C# Visual Studio.

1
First in what sense? The oldest? The newest? Why do you want to do anything with the messages in the Outbox folder? Doing that will cancel the message submission.Dmitry Streblechenko
I ideally have to select the "Newest" mail from outbox folder Once it is selected it has to perform the click action on button click on the which is there on top inside the Tab. Can yuh Assest me how to do this?Soumya Chiniwar
I have to do all this programmaticallySoumya Chiniwar
Why? The message is in the Outbox folder and it about to be sent out and moved to the Sent Items folder. Why do you want to do anything with that message?Dmitry Streblechenko
I have an application where i want to Insert the Outbox mail into that store...Not that i want to do the cut paste operation .Let the document remain in outbox but should also go in to the store where i want to store it.Soumya Chiniwar

1 Answers

0
votes

You can use the GetDefaultFolder method of the Store class. This method is similar to the GetDefaultFolder method of the NameSpace object. The difference is that this method gets the default folder on the delivery store that is associated with the account, whereas NameSpace.GetDefaultFolder returns the default folder on the default store for the current profile.

Sub ChangeCurrentFolder() 
 Dim myNamespace As Outlook.NameSpace 
 Set myNamespace = Application.GetNamespace("MAPI") 
 Set Application.ActiveExplorer.CurrentFolder = _ 
 myNamespace.GetDefaultFolder(olFolderOutbox)  
End Sub

Use the GetFirst method of the Items class to get the first object in the collection. Returns Nothing if no first object exists, for example, if there are no objects in the collection. To ensure correct operation of the GetFirst, GetLast, GetNext, and GetPrevious methods in a large collection, call GetFirst before calling GetNext on that collection and call GetLast before calling GetPrevious. To ensure that you are always making the calls on the same collection, create an explicit variable that refers to that collection before entering the loop.

You may find the How To: Get any standard / default folder in Outlook article helpful.