Saving emails from within access

G

Guest

I have a problem with the code listed below, my access database has Outllook
EntityID's stored in it & I would like to now save the actual emails to a
certain directory, the problem is that the EntityID's are from different
computers, I need to be able to skip messages that cause an error.

Code:
Private Sub Command74_Click()
On Error GoTo Err_Command74_Click:
Dim rs As Object
rs.MoveFirst
Do
Set myolApp = CreateObject("Outlook.Application")
Set myNameSpace = myolApp.GetNamespace("MAPI")
If Me.Category = "SENT" Then
Set myFolder = myNameSpace.GetDefaultFolder(5)
ElseIf Me.Category = "RECEIVED" Then
Set myFolder = myNameSpace.GetDefaultFolder(6)
End If
Set myMail = myNameSpace.GetItemFromID(Me.OutlookID)
myMail.SaveAs "c:\eMail\" & Me.OutlookID & ".msg" & olMSG
rs.MoveNext
Loop While Not rs.EOF
Exit_Command74_Click:
Exit Sub
Err_Command74_Click:
Resume Exit_Command74_Click:
End Sub
 
J

John Nurick

That the Outlook EntryID can be quite long - longer, AFAIR, than the 255
character limit on Windows paths. That means that this line

myMail.SaveAs "\\Main\c\Emails\" & ID & ".msg" & olMSG

is not safe.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top