Linking to an access record from an email

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jonnyboy
    New Member
    • Aug 2007
    • 31

    Linking to an access record from an email

    Hello,

    I've developed an access database to track work against team plans and organizational objectives.

    I'm trying to implement a feature but I'm not sure where to start. I'm wondering if there is any way of opening a database at a specific record by using a hyperlink in an email.

    For example, I want users to be able to receive an email like

    "I've assigned this task to you. Please check it out on the database (hyperlink)"

    Is there any way of passing arguments to Access in this way?
    Any suggestions appreciated.
  • puppydogbuddy
    Recognized Expert Top Contributor
    • May 2007
    • 1923

    #2
    see this link for code that might help you get started, and give you something that you can adapt and build on.

    Access Reading Outlook E-Mails from Access

    Comment

    • jonnyboy
      New Member
      • Aug 2007
      • 31

      #3
      Hi,

      Thanks for the reply, Puppydogbuddy.
      I'm a little confused as to how to start with this one; am I right that this bit of code actually monitors the inbox?

      The database wouldn't always be open, so I wonder if there would be any way of passing arguments from a hyperlink in an email to start the database and then go to a specified record?

      I'd rather not tamper with my colleagues' inboxes if possible!

      Comment

      • puppydogbuddy
        Recognized Expert Top Contributor
        • May 2007
        • 1923

        #4
        OK, here is an example that I found on a public forum. The code is credited to Jim Everist. I do not know HTML, so I leave it to you to modify the HTML to the specifics of your application. As to opening your database to a specific record, you can use the OpenForm of the DoCmd with a where clause argument....
        For example (assuming where clause returns a text value), DoCmd.OpenForm "YourForm", ,, "[SomeField] = '" & YourVariable & "'"


        Code:
        'Set the mail .BodyFormat to HTML (= olFormatHTML) and then use HTML tags inside of the .HTMLBody property like this:
        
        Sub SendFileLink()
        Dim sSubject As String, sBody As String, sEmail As String
        
        sSubject = "Test File Hyperlink Email"
        sBody = sBody & "This is the filename link:" & vbCrLf
        sBody = sBody & "<A href=""file://server-name/share/folder/folder/folder/file""><FONT face=Verdana size=2>filename</FONT></A>"
        sEmail = "emailname@company.com"
        
        Dim oApp As New Outlook.Application
        Set oApp = New Outlook.Application
        
        Dim oMail As Object
        Set oMail = oApp.CreateItem(olMailItem)
        
        oMail.BodyFormat = olFormatHTML
        oMail.HTMLBody = sBody
        oMail.Subject = sSubject
        oMail.To = sEmail
        
        oMail.Send
        
        Set oMail = Nothing
        Set oApp = Nothing
        
        End Sub

        Comment

        Working...