-
Can someone help me Urgent!
I need to write a Visual Basic program in VB5 to use the Outlook Object LIbrary to access the faxes, mails in Outlook 2000
I would need to extract the attachments that comes with the individual mail.
and delete away the mail from Outlook 2000.
There is no exchange server involved.
I need the sample program urgently, please email [email protected] if you know the soln.
-
you could do worse than have a look at:
http://www.vb-world.net/demos/autoemail/
-
What does this program do ?
I do not need to auto mail? I just need to be able to extract the attachements that's all.
-
Code:
Sub ReadEmail()
Dim oApp As Outlook.Application
Dim oNameSpace As Outlook.NameSpace
Dim oFolder As Outlook.MAPIFolder
Dim oMailItem As Object
Dim sMessage As String
Set oApp = New Outlook.Application
Set oNameSpace = oApp.GetNamespace("MAPI")
oNameSpace.Logon "MyProfile", , False, True
Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
For Each oMailItem In oFolder.Items
With oMailItem
If oMailItem.UnRead = True Then
If oMailItem.Attachments.Count > 0 Then
oMailItem.Attachments.Item(1).SaveAsFile "C:\Temp\OutlookAttachments\" & _
oMailItem.Attachments.Item(1).Filename
End If
End If
End With
Next oMailItem
Set oMailItem = Nothing
Set oFolder = Nothing
Set oNameSpace = Nothing
Set oApp = Nothing
End Sub
-
Quote:
Originally posted by Mark Sreeves
Code:
Sub ReadEmail()
Dim oApp As Outlook.Application
Dim oNameSpace As Outlook.NameSpace
Dim oFolder As Outlook.MAPIFolder
Dim oMailItem As Object
Dim sMessage As String
Set oApp = New Outlook.Application
Set oNameSpace = oApp.GetNamespace("MAPI")
oNameSpace.Logon "MyProfile", , False, True
Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
For Each oMailItem In oFolder.Items
With oMailItem
If oMailItem.UnRead = True Then
If oMailItem.Attachments.Count > 0 Then
oMailItem.Attachments.Item(1).SaveAsFile "C:\Temp\OutlookAttachments\" & _
oMailItem.Attachments.Item(1).Filename
End If
End If
End With
Next oMailItem
Set oMailItem = Nothing
Set oFolder = Nothing
Set oNameSpace = Nothing
Set oApp = Nothing
End Sub
-
I am new to MAPI or this Outlook Object Library. could you please write comments on the code
btw, oNameSpace.logon" " myprofile"
what does it do? I don't have an Exchange SErver, do I still need to logon?
Quote:
Originally posted by Mark Sreeves
Code:
Sub ReadEmail()
Dim oApp As Outlook.Application
Dim oNameSpace As Outlook.NameSpace
Dim oFolder As Outlook.MAPIFolder
Dim oMailItem As Object
Dim sMessage As String
Set oApp = New Outlook.Application
Set oNameSpace = oApp.GetNamespace("MAPI")
oNameSpace.Logon "MyProfile", , False, True
Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
For Each oMailItem In oFolder.Items
With oMailItem
If oMailItem.UnRead = True Then
If oMailItem.Attachments.Count > 0 Then
oMailItem.Attachments.Item(1).SaveAsFile "C:\Temp\OutlookAttachments\" & _
oMailItem.Attachments.Item(1).Filename
End If
End If
End With
Next oMailItem
Set oMailItem = Nothing
Set oFolder = Nothing
Set oNameSpace = Nothing
Set oApp = Nothing
End Sub