L
Lee Moore
The following code gives me an "Exception from HRESULT: 0xC6204005" or
"Exception from HRESULT: 0xCA404005" error. I have tried adjusting the path
but no luck. Everything looks valid to me. The only code that is not
directly from MS is the declaration for the mailbox, oMailbox. I could not
figure out the exact object to use, so I just used a generic Object and made
the assignment. Any help would be most appreciated.
Dim oApp As New Outlook.Application
Dim oNS As Outlook.NameSpace
oNS = oApp.GetNamespace("MAPI")
Dim oMailbox As Object
'Retrieve an Item that has custom and built-in properties
Dim oFolder As Outlook.MAPIFolder
Dim oMsg As Outlook.MailItem
Dim oAttach As Outlook.Attachment
Dim dtParts() As String
Dim fn As String
Try
oMailbox = oNS.Folders.Item("Mailbox - Lee Moore")
oFolder = oMailbox.Folders("EnrSumm")
For Each oMsg In oFolder.Items
For Each oAttach In oMsg.Attachments
dtParts = Split(Microsoft.VisualBasic.Left(oMsg.CreationTime,
Len(oMsg.CreationTime) - (Len(oMsg.CreationTime) - InStr(oMsg.CreationTime,
" "))), "/")
If Len(dtParts(0)) < 2 Then
dtParts(0) = "0" & dtParts(0)
End If
If Len(dtParts(1)) < 2 Then
dtParts(1) = "0" & dtParts(1)
End If
fn = "c:\\enrsumm\\" & dtParts(0) & dtParts(1) & dtParts(2) & ".tgz"
MsgBox(fn)
oAttach.SaveAsFile(fn)
Next
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
"Exception from HRESULT: 0xCA404005" error. I have tried adjusting the path
but no luck. Everything looks valid to me. The only code that is not
directly from MS is the declaration for the mailbox, oMailbox. I could not
figure out the exact object to use, so I just used a generic Object and made
the assignment. Any help would be most appreciated.
Dim oApp As New Outlook.Application
Dim oNS As Outlook.NameSpace
oNS = oApp.GetNamespace("MAPI")
Dim oMailbox As Object
'Retrieve an Item that has custom and built-in properties
Dim oFolder As Outlook.MAPIFolder
Dim oMsg As Outlook.MailItem
Dim oAttach As Outlook.Attachment
Dim dtParts() As String
Dim fn As String
Try
oMailbox = oNS.Folders.Item("Mailbox - Lee Moore")
oFolder = oMailbox.Folders("EnrSumm")
For Each oMsg In oFolder.Items
For Each oAttach In oMsg.Attachments
dtParts = Split(Microsoft.VisualBasic.Left(oMsg.CreationTime,
Len(oMsg.CreationTime) - (Len(oMsg.CreationTime) - InStr(oMsg.CreationTime,
" "))), "/")
If Len(dtParts(0)) < 2 Then
dtParts(0) = "0" & dtParts(0)
End If
If Len(dtParts(1)) < 2 Then
dtParts(1) = "0" & dtParts(1)
End If
fn = "c:\\enrsumm\\" & dtParts(0) & dtParts(1) & dtParts(2) & ".tgz"
MsgBox(fn)
oAttach.SaveAsFile(fn)
Next
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try