Link to home
Start Free TrialLog in
Avatar of Lou Dufresne
Lou DufresneFlag for United States of America

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\CopeXdock.mdb")


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("OutlookExpress.Application")
    Set emailItem = appOutlook.CreateItem(0)
    Set emailAttachments = emailItem.Attachments
    Set emailAttach = emailAttachments.Add(strAttachmentLocation, 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


SOLUTION
Avatar of Mikal613
Mikal613
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lou Dufresne

ASKER

Thanks you for your assistance.

Lou