Each Record in Access report Should go as mail to the email specified in report

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rahul2310
    New Member
    • Oct 2013
    • 62

    Each Record in Access report Should go as mail to the email specified in report

    I have a report which contains Employee Code,Name and E-Mail Address.
    I want auto generating button next to each row.
    Which will email record only in that row to the email id specified in that row.
  • topher23
    Recognized Expert New Member
    • Oct 2008
    • 234

    #2
    Okay, here's what you do.
    1. Put a command button in the detail section of your report. You probably want to set the "Display When" property to "Screen Only," so it doesn't show up if you print your report.
    2. If you use Outlook in your company, you can use Outlook Automation methodology to send your email. If you don't want to rely on Outlook, check out my post about using SMTP via GMail.
    3. If you decide to import my SendSMTP function, the only code you need in your command button will look like this:
    Code:
    SendSMTP Me.[EmployeeEmail], "[Your Subject line]", "Some body text " & Me.[Field1] & "; " & me.[Field2]
    If you go with Outlook automation, you'll apply the same concept with the Outlook syntax instead.

    Comment

    • rahul2310
      New Member
      • Oct 2013
      • 62

      #3
      thanks for reply topher23 i tried ur function but Its throwing error "sub or function not defined"

      Comment

      • topher23
        Recognized Expert New Member
        • Oct 2008
        • 234

        #4
        Whoops! I noted that problem previously and thought I'd already fixed it on the blog post. The function calls another function that it uses to iterate adding attachments based on the number of semicolons in the string. Here's the other function that you'll need to paste into the module with the SendSMTP function:
        Code:
        Public Function CountInStr(StringToCheck As String, StringToFind As String) As Long
            CountInStr = (Len(StringToCheck) - Len(Replace(StringToCheck, StringToFind, ""))) / Len(StringToFind)
        End Function
        Last edited by topher23; Oct 29 '13, 07:14 PM. Reason: random string made it into the code

        Comment

        • rahul2310
          New Member
          • Oct 2013
          • 62

          #5
          thanks topher23 it works like champ

          Comment

          • topher23
            Recognized Expert New Member
            • Oct 2008
            • 234

            #6
            always happy to help!

            Comment

            Working...