Lou Dufresne
asked on
Need a method to email a MDB file by way of MS Outlook, not Outlook Express from within MS Access
I received the following code from an EE member but it does not work with Outlook
Any ideas on how to modify it.
I pass to the function the parameters using a macro with the following function
RunCode
FunctionName EmailFile ("Loudufresne@qwest.net",F :\Qwest\Co peXdock.md b")
This is the code that does not work with Outlook.
Public Function EmailFile(ByVal strEmailAddress As String, ByVal strAttachmentLocation As String)
Dim appOutlook As Object
Dim emailItem As Object
Dim emailAttachments As Object
Dim emailAttach As Object
Set appOutlook = CreateObject("OutlookExpre ss.Applica tion")
Set emailItem = appOutlook.CreateItem(0)
Set emailAttachments = emailItem.Attachments
Set emailAttach = emailAttachments.Add(strAt tachmentLo cation, 1)
emailItem.Recipients.Add (strEmailAddress)
emailItem.Subject = "Daily XDock Report (" & Format(Now(), "YYYYMMDD") & ")"
emailItem.Body = "Please find attached, Access Database containing today's Xdock data , Thank You." & vbCrLf
emailItem.Send
Set emailAttach = Nothing
Set emailAttachments = Nothing
Set emailItem = Nothing
Set appOutlook = Nothing
End Function
Any ideas on how to modify it.
I pass to the function the parameters using a macro with the following function
RunCode
FunctionName EmailFile ("Loudufresne@qwest.net",F
This is the code that does not work with Outlook.
Public Function EmailFile(ByVal strEmailAddress As String, ByVal strAttachmentLocation As String)
Dim appOutlook As Object
Dim emailItem As Object
Dim emailAttachments As Object
Dim emailAttach As Object
Set appOutlook = CreateObject("OutlookExpre
Set emailItem = appOutlook.CreateItem(0)
Set emailAttachments = emailItem.Attachments
Set emailAttach = emailAttachments.Add(strAt
emailItem.Recipients.Add (strEmailAddress)
emailItem.Subject = "Daily XDock Report (" & Format(Now(), "YYYYMMDD") & ")"
emailItem.Body = "Please find attached, Access Database containing today's Xdock data , Thank You." & vbCrLf
emailItem.Send
Set emailAttach = Nothing
Set emailAttachments = Nothing
Set emailItem = Nothing
Set appOutlook = Nothing
End Function
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Lou