Results 1 to 15 of 15
  1. #1
    WAVP375 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171

    Email from access form

    I have established a file of scanned documents, both JPG and PDF. In access I have created a table with the document name. Knowing the path I can access the document from a list box and display it in a form. I can then print it if I chose to. Now that I have the document I want to add a button to send the email and a text box to input the email address , then press the email button.



    I am lost, I'm sure this has been done but I've not been able to find it yet.

    Thanks

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Outlook automation is one way. Here's a start:

    http://support.microsoft.com/?kbid=161088
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    WAVP375 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    Being very shallow in VBA, I copied the code you suggested and pasted it into my module. Mad changes for my specific use and got nowhere with it. Not understanding what was trying to be done it was hard to debug.. Thanks, I was hoping to find a less complicated way to get it done. I'm learning, if it seems like a simple idea there must be a lot of code behind it.

    Thanks again

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    You can use a macro,
    use the SENDTO command.
    or
    Use it to command in VB button click event.

  5. #5
    WAVP375 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    No success with either suggestion. I did find another site with some code that I think I understand but still have a problem with. The following code was copied and pasted into a module changing only the path, file name and the To:. When attempting to debug I get the error 'User defined type not defined' on the third Dim statement. There may be more issues but cant get by this one. The code is in the frmPdfDocumentDisplay and the frmSearch is open at the time.

    Any thoughts or suggestions


    Public Sub SendDocument()
    Dim strGetFilePath As String
    Dim strGetFileName As String
    strGetFilePath = "[Forms]![frmPdfDocumentDisplay]![ImagePath]"
    strGetFileName = "[Forms]![frmSearch]![DocumentTitle]"
    Dim appOutLook As Outlook.Application
    Dim MailOutLook As Outlook.MailItem
    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)
    With MailOutLook
    .BodyFormat = olFormatRichText
    .To = "[Forms]![frmPdfDocumentDisplay]![EmailAddress]"
    ''.cc = ""
    ''.bcc = ""
    .Subject = "From Document Archives"
    .HTMLBody = ""
    .Attachments.Add (strFilePath & strGetFileName)
    .Send
    End With
    End Sub

  6. #6
    WAVP375 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    Since I have the document that I want to send displayed in frmPdfDocumentDisplay, would it be possible to capture a screenshot and email it programmatically?

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Doesn't sound like you did steps 4 and 5, though you'd refer to whatever version you have. You don't put the form references in quotes.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    WAVP375 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    Thanks for the point on quotes. What are steps 4 and 5? How about the screenshot idea?

    Thanks

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Steps 4 and 5 from the link I posted will resolve the error you're getting. An alternative is late binding, which I'd use anyway if there could be different versions of Outlook.

    I've never tried to capture a screen shot in code.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    WAVP375 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    Still looking for the solution. I have tried several suggestions from various sites and all have a common problem. I get a compile error on the code line Dim oOutlook As Outlook.Application. The entire code set I am using is a follows. Any other suggestions is desired as well. Sounds like it should something small.

    Private Sub SendEmail_Click()
    Dim FileName As String
    Dim FilePath As String
    Dim oOutlook As Outlook.Application
    Dim oEmailItem As MailItem

    FileName = Me.DocumentTitle
    FilePath = [Forms]![frmSearch]![ImagePath]

    If Outlook Is Nothing Then
    Set Outlook = New Outlook.Application
    End If

    Set oEmailItem = oOutlook.CreateItem(olMailItem)

    With oEmailItem
    .To Me.EmailAddress
    .Subject "New Document"
    .Attachment.Add FilePath
    .Send
    End With

    Set oEmail = Nothing
    Set oOutlook = Nothing

    End Sub

  11. #11
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Did you do this



    This is one reason why you'd get that error.


    Sent from my iPhone using Tapatalk

  12. #12
    WAVP375 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    I do not have Microsoft Outlook 8.0 Object Model I do have Microsoft Outlook 16.0 Object library.
    Is that something unique to the operating system ?

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Did you miss

    Quote Originally Posted by pbaldy View Post
    though you'd refer to whatever version you have.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    WAVP375 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    Thanks pbaldy, I finally saw the light. I did what you suggested and it now works fine..

  15. #15
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 11-07-2016, 11:18 AM
  2. Replies: 2
    Last Post: 05-23-2016, 01:28 PM
  3. Replies: 1
    Last Post: 05-01-2014, 11:37 AM
  4. Replies: 22
    Last Post: 04-24-2014, 01:56 PM
  5. Email Web Form to Access
    By cvclubs in forum Access
    Replies: 4
    Last Post: 05-29-2010, 07:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums