Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25
  1. #16
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518

    I didn't know if switching email methods might solve the issue, so I figured on tackling it then if it still happens. Do you use Outlook?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  2. #17
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    In answer to your PM (technical discussion should take place on the thread):

    Yes, i did, but i don't know where to put that code. I don't know how to switch method. Any advice? Many thanks!

    the automation code in the link is a public function. You'd paste the whole bit into a standard module. Then you'd replace the SendObject line in your code with a call to his function:

    SendEmail rsEmails!email, "Subject", strBody,...

    and within the function change the line assigning the body to:

    .HTMLBody = strBody
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #18
    TManolache is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    12
    I implemented the function and call it. It's amazing!
    Switching to this email method:
    - solved the error
    - html is in place
    - i don't have to give permission for every email
    Yes, i use Outlook.
    Many, many thanks. You're a genius!

  4. #19
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help! You'll get a lot of arguments on the "genius" comment, and rightly so.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #20
    TManolache is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    12
    Well, i'll take them as off topic.

  6. #21
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    LOL! I'm not a genius, just a good thief of other people's work.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #22
    TManolache is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    12
    Reality check! Unfortunately i have another issue with the code. each email that it generates it appends the new strBody content in the email without clearing the previews value. so the last email contains all the activities for everybody instead of just one person activity. Looks like i need a command to clear strBody value when move next. Any ideas?

    Code:
    Public Function SendTestEMail()  Dim rsData As DAO.Recordset
      Dim rsEmails As DAO.Recordset
      Dim strBody As String
        Set rsEmails = CurrentDb.OpenRecordset("SELECT Email FROM oameni;")
      While Not rsEmails.EOF
        Set rsData = CurrentDb.OpenRecordset("SELECT * FROM [oameni si activitati q] WHERE Email='" & rsEmails!Email & "';")
        While Not rsData.EOF
          'code to build email body using rsData record
          strBody = strBody & "<b>ACTIVITATE</b>" & "<br>" & rsData!Activitate & "<br>" & "<b>DESCRIERE ACTIVITATE</b>" & "<br>" & rsData![Descriere activitate] & "<p>" & rsData!link & "<p>"
          'Attachments.Add ("C:\Users\Theodor\Desktop\focus online.docx")
          rsData.MoveNext
        Wend
        'code to send email
        SendEmail rsEmails!Email, "activitati Baneasa Forest Run", strBody, True
        ', , rsData!Path
        rsData.Close
        rsEmails.MoveNext
    Wend
    End Function

  8. #23
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Ah, missed that, sorry. Before the inner loop, reset the variable:

    ...
    strBody = ""
    While Not rsData.EOF
    ...
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #24
    TManolache is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    12
    Yep, this is it! Thanks!
    ps. no more praising.

  10. #25
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    No problemo!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Send Emails from outlook
    By WhiskyLima in forum Access
    Replies: 8
    Last Post: 08-11-2014, 11:02 AM
  2. Loop Through Query, Send Multiple Emails
    By tdoolittle in forum Reports
    Replies: 6
    Last Post: 05-12-2014, 09:33 PM
  3. Replies: 9
    Last Post: 12-18-2013, 02:49 PM
  4. Programming Access to Send Emails?
    By BMW150 in forum Access
    Replies: 8
    Last Post: 09-17-2013, 06:14 PM
  5. Send Emails Automatically
    By cbrsix in forum Programming
    Replies: 10
    Last Post: 10-19-2012, 10:52 AM

Tags for this Thread

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