hi John,
Thanks for sharing that to me, i really appreciate that!
I have another question here:
i) the example you gave me is to retrieve all mails from Outlook and shown by using console application. However, what i want is to retrieve and save the mails in another folder created by user.
Can it possible to be done by using VB .NET?
Erm...let me cut it short!
What i want is to move (or copy) all mails from outlook to desktop (created folder).
And i know the example you gave me can retrieve all the mails, but how to copy the mails to desktop?
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i AsInteger ' Create Outlook application. Dim oApp As Outlook.Application = New Outlook.Application ' Get Mapi NameSpace. Dim oNS As Outlook.NameSpace = oApp.GetNamespace("mapi")
oNS.Logon("YourValidProfile", Missing.Value, False, True) ' TODO: ' Get Messages collection of Inbox. Dim oInbox As Outlook.MAPIFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox) Dim oItems As Outlook.Items = oInbox.Items If oItems.Count <= 0 Then MessageBox.Show("There is no any mails in your inbox on :" & Date.Today()) Else MessageBox.Show("Total numbers of mails : " & oItems.Count & vbNewLine & _
"Are you sure want to move all the MS Outlook Inbox Mails?", "Confirmation", _
MessageBoxButtons.OKCancel, MessageBoxIcon.Question)
If MsgBoxResult.OK Then Dim myPath AsString = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\MyOutlookMail\" & Date.Today() For i = 0 To oItems.Count - 1
oItems.SaveAs("C:\" & myPath & ".msg") Next Else oNS.Logoff() EndIf EndIf
EndSub
**These are my codes to move all the mails from outlook to the specific folder. Currently i am using VB .NET 2003,and there is an error message says that :
"An unhandled exception of type 'System.MissingMemberException' occurred in microsoft.visualbasic.dll Additional information: Public member 'SaveAs' on type 'ItemsClass' not found."
What cause this problem occured? (my programming logic is wrong ) Am i need to import any namespace for this
i have try the code that you gave me, and make a little changes to it.
However, the error occured as below :
"An unhandled exception of type 'System.IO.DirectoryNotFoundException' occurred in microsoft.visualbasic.dll Additional information: The operation failed."
My code are as below:
oItems.Item(i).SaveAs("C:\Documents and Settings\Desktop\MyOutlookInbox" _
& Date.Today & "(" & i & ")" & ".msg")
I do not know why the operation failed. Can you help em to figure out?
Hi, I have tried so many times to get total number of unread message in the inbox foloder of Outlook express. Each time I get 0 as result.
I tried with the code given above by powerteh also but this time I am getting error "The server is not available. Contact your administrator if this condition persists." at line oNS.Logon("YourValidProfile", Missing.Value, False, True) even I use username and password properly.
Actually I want to make a scheduler service which will give message whenever any new(unread) message come to inbox.
Please help me regading this as I am beginner for outlook programming.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.