gmaxey
09-20-2012, 03:07 AM
I have some simple code that saves an OUTLOOK attachment (Word 2010 document with content controls) to a file.
For lngTmp = 1 To olAttachments.Count
strAttachment_FileName = strTempFolderPath & Application.PathSeparator & olAttachments.Item(lngTmp).DisplayName
If fcnCheckAttachments(strAttachment_FileName) = True Then
'Save the attachment to the temporary folder
olAttachments.Item(1).SaveAsFile strAttachment_FileName
bAttachmentSaved = True
Exit For
End If
Next lngTmp
If Not bAttachmentSaved Then
'The attachment was not found
olItem.UnRead = True
olItem.Move olFolder.Folders("Invalid Forms")
GoTo ProcessNext
End If
When the process runs, the resulting file is corrupt and can no longer be opened in Word.
I can open the attachment while in OUTLOOK, I can save the attachment manually and then open it, but if I use the SaveAsFile method, I can not longer open the file.
Cross posted: http://answers.microsoft.com/en-us/office/forum/office_2010-customize/olattachmentsitem1saveasfile-results-in-corrupted/f992866b-3775-482f-be5d-42c1a7534df8
Any ideas? Thanks,
For lngTmp = 1 To olAttachments.Count
strAttachment_FileName = strTempFolderPath & Application.PathSeparator & olAttachments.Item(lngTmp).DisplayName
If fcnCheckAttachments(strAttachment_FileName) = True Then
'Save the attachment to the temporary folder
olAttachments.Item(1).SaveAsFile strAttachment_FileName
bAttachmentSaved = True
Exit For
End If
Next lngTmp
If Not bAttachmentSaved Then
'The attachment was not found
olItem.UnRead = True
olItem.Move olFolder.Folders("Invalid Forms")
GoTo ProcessNext
End If
When the process runs, the resulting file is corrupt and can no longer be opened in Word.
I can open the attachment while in OUTLOOK, I can save the attachment manually and then open it, but if I use the SaveAsFile method, I can not longer open the file.
Cross posted: http://answers.microsoft.com/en-us/office/forum/office_2010-customize/olattachmentsitem1saveasfile-results-in-corrupted/f992866b-3775-482f-be5d-42c1a7534df8
Any ideas? Thanks,