G
Greg
hi,
I have the following code i'm having trouble with. it appears to be in the
objects set up. any help is appreciated.
---------------------------------------------
Sub SaveAttachment(MyMail As MailItem)
Dim strID As String
Dim objNS As Outlook.NameSpace
Dim objMail As Outlook.MailItem
Dim objAttachments As Outlook.Attachments
Dim strPath As String, strFile As String
strPath = "\\ad\gbs$\Download\HM\"
strID = MyMail.EntryID
Set objNS = Application.GetNamespace("MAPI")
Set objMail = olNS.GetItemFromID(strID)
Set objAttachments = objMail.Attachments
lngCounter = objAttachments.Count
If lngCounter > 0 Then
'iterate the attachment object collection
For i = lngCounter To 1 Step -1
strFile = objAttachments.Item(i).FileName
strFile = strPath & strFile
Debug.Print strFile
' save the attachment file
objAttachments.Item(i).SaveAsFile strFile
Next i
End If
Set objMail = Nothing
Set objNS = Nothing
Set objAttachments = Nothing
End Sub
I have the following code i'm having trouble with. it appears to be in the
objects set up. any help is appreciated.
---------------------------------------------
Sub SaveAttachment(MyMail As MailItem)
Dim strID As String
Dim objNS As Outlook.NameSpace
Dim objMail As Outlook.MailItem
Dim objAttachments As Outlook.Attachments
Dim strPath As String, strFile As String
strPath = "\\ad\gbs$\Download\HM\"
strID = MyMail.EntryID
Set objNS = Application.GetNamespace("MAPI")
Set objMail = olNS.GetItemFromID(strID)
Set objAttachments = objMail.Attachments
lngCounter = objAttachments.Count
If lngCounter > 0 Then
'iterate the attachment object collection
For i = lngCounter To 1 Step -1
strFile = objAttachments.Item(i).FileName
strFile = strPath & strFile
Debug.Print strFile
' save the attachment file
objAttachments.Item(i).SaveAsFile strFile
Next i
End If
Set objMail = Nothing
Set objNS = Nothing
Set objAttachments = Nothing
End Sub