S
Steve Le Monnier
Can anybody help with the following: I have some old VB6 code that loops
through my inbox looking for emails with attachments and then save them to
the hard drive. The code is very simplistic so I thought it would be dead
easy to migrate it to C#, however it is proving more difficult than I first
thought.
The VB code is as follows:
Set oSession = CreateObject("MAPI.Session")
oSession.Logon("Outlook", , False)
Set oInbox = oSession.Inbox
For Each oMsg In oInbox.Message
oMsg.Attachments(1).WriteToFile {path}
Next
My C# alternative so far is:
MAPI.Session oSession = new MAPI.Session();
MAPI.Folder oFolder;
oSession.Logon("Outlook", vEmpty, false, true, 0, true, vEmpty);
oFolder = (MAPI.Folder)oSession.Inbox;
MAPI.Messages oMsgs = (MAPI.Messages)oFolder.Messages;
The problem I am having is not being able to loop through the messages so I
can check who sent it and does it have an attachment?
Is it possible to translate the VB6 code to C#?
Many thanks
Steve Le Monnier
through my inbox looking for emails with attachments and then save them to
the hard drive. The code is very simplistic so I thought it would be dead
easy to migrate it to C#, however it is proving more difficult than I first
thought.
The VB code is as follows:
Set oSession = CreateObject("MAPI.Session")
oSession.Logon("Outlook", , False)
Set oInbox = oSession.Inbox
For Each oMsg In oInbox.Message
oMsg.Attachments(1).WriteToFile {path}
Next
My C# alternative so far is:
MAPI.Session oSession = new MAPI.Session();
MAPI.Folder oFolder;
oSession.Logon("Outlook", vEmpty, false, true, 0, true, vEmpty);
oFolder = (MAPI.Folder)oSession.Inbox;
MAPI.Messages oMsgs = (MAPI.Messages)oFolder.Messages;
The problem I am having is not being able to loop through the messages so I
can check who sent it and does it have an attachment?
Is it possible to translate the VB6 code to C#?
Many thanks
Steve Le Monnier