Sending emails from Access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Neekos
    New Member
    • Aug 2007
    • 111

    Sending emails from Access

    I have a table that was imported from an excel spreadsheet. It will probably be imported on a daily basis (as it will change daily). There are 4 different types of accounts in this table. I have created queries to seperate these 4 accounts. One of the fields in the table is their email address. I want to be able to email the same message to all of the people in each group (the message will be different depending on the account).

    In a nutshell - i want to be able to send the same email to all of the people in a query at once.

    Is this possible?
  • Jim Doherty
    Recognized Expert Contributor
    • Aug 2007
    • 897

    #2
    Originally posted by Neekos
    I have a table that was imported from an excel spreadsheet. It will probably be imported on a daily basis (as it will change daily). There are 4 different types of accounts in this table. I have created queries to seperate these 4 accounts. One of the fields in the table is their email address. I want to be able to email the same message to all of the people in each group (the message will be different depending on the account).

    In a nutshell - i want to be able to send the same email to all of the people in a query at once.

    Is this possible?

    If you are talking about sending ONCE the same message to ALL email addresses of a particular account type in ONE mail then the logic would be to loop through a dataset containing all the email addresses that comprise the 'particular' account type, appending a semicolon after each email address until a continuous string of semicolon separated email addresses was arrived at.

    This string of email addresses could then be used in the SEND TO section of the email in Outlook (if that is the email client) The body of the email could be manipulated for the account type via Office automation methods. The textual body of the email could be stored in a table referenced by field to identify 'which' account type relates to 'which' email text body.

    Its difficult to advise you further on this at the moment other than to provide some logic because there are many valid ways of doing it either by creating your queries to create your datasets 'in isolation' and working individually off of those, or indeed looping via recordset code and by consequence determining logic that way without using stored queries.

    In reality you only need ever be working off one main table that merely gets appended to each day but which would have whatever flag fields become necessary to account for those records that 'already had' emails sent out (or at least 'dealt with' so that in essence you could in effect largely forget them - you wouldnt want to be sending emails out twice or however many times... if you understand me)

    It really depends on your own strategy as surrounds the imports, how you intend dealing with those, how you account for those already have had emails sent etc etc.....but in short yes it is possible

    Hope this goes someway to helping you

    Regards

    Jim

    Comment

    • Neekos
      New Member
      • Aug 2007
      • 111

      #3
      Thanks jim!

      Here's what i have so far (just a start)....i get this to work by placing my own email address in email.

      [CODE=vb]Private Sub Command0_Click( )

      Dim Email As String
      Dim objOutlook As Outlook.Applica tion
      Dim objEmail As Outlook.MailIte m

      Email = "me@me.com"

      Set objOutlook = CreateObject("O utlook.applicat ion")

      Set objEmail = objOutlook.Crea teItem(olMailIt em)

      With objEmail

      .To = Email
      .Subject = "Your TEST edocs"
      .Body = "This is just a test"
      .Send
      End With

      Set objEmail = Nothing

      End Sub[/CODE]


      Now i know what i need to do, im just not sure about how to go about it. I need to create a loop that checks to see which account each user belongs to (acct1, acct2, acct3, etc.) and then concatenate their email address into seperate strings (for each account) and delimeted with semicolons.

      Also, is it possible to change who the email is sent FROM? Right now it is just sending from me, and i belong to many different groups that the emails need to be sent from. Is this possible? i tried to use .From in my With clause but that didnt work.

      Comment

      • Neekos
        New Member
        • Aug 2007
        • 111

        #4
        Also, i have built queries to seperate the different accounts, if that would make it easier.

        Comment

        • Jim Doherty
          Recognized Expert Contributor
          • Aug 2007
          • 897

          #5
          Originally posted by Neekos
          Also, i have built queries to seperate the different accounts, if that would make it easier.

          ok well this is fairly simple and small to do but its evening time and a bit late here with me now and so I am gonna have a look at this personally tomorrow morning offline and maybe even create you a small database in the process which I could mail to you... if you PM me with your email address
          I'll send it once I've done it and also importantly post back the logic here so that casual viewers can also benefit

          Regards

          Jim

          Comment

          • Jim Doherty
            Recognized Expert Contributor
            • Aug 2007
            • 897

            #6
            Originally posted by Neekos
            Also, i have built queries to seperate the different accounts, if that would make it easier.
            OK Neekos,

            This db is now complete for you should you call back..

            Jim

            Comment

            • Mmmel
              New Member
              • Feb 2010
              • 52

              #7
              Hi Jim!

              This is EXACTLY what I want to do, as well as use a particular field from a table as the body of the email. I tried to PM you but, as I am a noob here I'm not sure I can. Is there any way you could get your little db to me so I can sneak your code? I've found/adapted code to send to one email (to one person), and compiled lots of others to try, but I keep getting lost! Please let me know what to do! THANKS! : )

              Comment

              Working...