email group customers (1 Viewer)

Gismo

Registered User.
Local time
Today, 13:45
Joined
Jun 12, 2017
Messages
1,298
Hi All,
Please assist, not sure how to email an attachment to a list of customers depending on my criteria from a query.
The list of customers will not always be the same so I can not type the email in manually into the macro emaildatabaseobject
 

Ranman256

Well-known member
Local time
Today, 06:45
Joined
Apr 9, 2015
Messages
4,339
I have a table of email groups:
Acctg, bob@acme.com
Acctg, sam@acme.com
IT, bob@acme.com
Ship, bob@acme.com
Ship, sam@acme.com


In a form , I can select the Group, and that batch of emails appears in a list box.
cycle thru the list, attach, and send.

(the code sends 1 email / person ,rather than 1 email to a batch email, since the code doesn't care how many emails it sends)


If the list is random,then the form has 2 lists:
1 source of persons, 1 of chosen.
user dbl-clicks the lstSrc , and its added to lstTarg.
 

Gismo

Registered User.
Local time
Today, 13:45
Joined
Jun 12, 2017
Messages
1,298
I have the same, in a table my emails, the query determines the list.
My issue is, I dont know how to do the actual mail to the list.
Not sure which command or code to use for this.
Macro "emaildatabaseobject" will not do the job
 

Cronk

Registered User.
Local time
Today, 20:45
Joined
Jul 4, 2013
Messages
2,771
You need to construct a concatenated string of the email addresses coming from the query. Use VBA to open a recordset based on the query and then loop through that recordset.

There will be be code samples in previous posts under Modules.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 05:45
Joined
Feb 28, 2001
Messages
27,131
When you are building the message, you can create the .Body of the message. If you are using either Outlook or CDO, you can set up the list of recipients at the same time by stepping through a list using recordset operations. For each recipient that should get the message you will need a user@address entry which you say you already have in the table. For the message object's .To property, concatenate each desired destination with a leading semi-colon. Then when you reach the end of the recordset that will be your distro list, use the RIGHT function to take off the leading semicolon. Then send your message.

Alternative: I always used to send myself the message and assured that I was never in the list of recipients obtained from the query. So I put my own e-mail first. Then when I added the recipients, I just added the semicolon and address.

Code:
(open a recordset to the table of potential recipients)

  Do Until recordset.EOF = True
    IF recordset!GroupName = (desired group name) THEN
      msg.To = msg.To & ";" & Trim$(recordset.UserAddress)
      END IF
    recordset.MoveNext
...
  End While
msg.Send

Obviously I've left stuff out there, but that's the general idea. Just tack on your list of recipients until you've run out. Separate them with semicolons.
 

Cronk

Registered User.
Local time
Today, 20:45
Joined
Jul 4, 2013
Messages
2,771
Alternative: I always used to send myself the message


I've done that at times too. However, when I did include my own email, I'd include it in the BCC list, which would also be used for the other recipients if they were a disparate group for privacy purposes.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 05:45
Joined
Feb 28, 2001
Messages
27,131
Actually, Cronk, I eventually did move my name from .To to .BCC because if someone did a Reply to All I would get deluged with project-oriented stuff I didn't need to keep.
 

Users who are viewing this thread

Top Bottom