Read emails from txt and add them to recipients

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Identis
Junior Coder
Posts: 26
Joined: Fri Mar 27, 2015 11:26 am

Read emails from txt and add them to recipients

Post by Identis » Fri Jan 13, 2023 1:01 pm

Hello,
I have txt file where I have users emails, number of users can change every month.
example txt:
[email protected]
[email protected]
[email protected]
How I can read and add these users to SMTPSendMail> command ?

Thanks in advance.

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Read emails from txt and add them to recipients

Post by Dorian (MJT support) » Fri Jan 13, 2023 2:28 pm

To loop through the email addresses and send them one by one, the structure would be something like this (assuming you already have the regular SMTPSendMail aspects accomplished) :

Code: Select all

readfile>d:\emails.txt,AllTxt
Separate>AllTxt,CRLF,Lines

let>readloop=1
repeat>readloop
  Let>thisemail=lines_%readloop%

  SMTPSendMail>%thisemail%,post.mail.com,me,myname,subject,body,

  let>readloop=readloop+1
Until>readloop,lines_count
Yes, we have a Custom Scripting Service. Message me or go here

Identis
Junior Coder
Posts: 26
Joined: Fri Mar 27, 2015 11:26 am

Re: Read emails from txt and add them to recipients

Post by Identis » Mon Jan 16, 2023 6:00 am

Dorian (MJT support) wrote:
Fri Jan 13, 2023 2:28 pm
To loop through the email addresses and send them one by one, the structure would be something like this (assuming you already have the regular SMTPSendMail aspects accomplished) :

Code: Select all

readfile>d:\emails.txt,AllTxt
Separate>AllTxt,CRLF,Lines

let>readloop=1
repeat>readloop
  Let>thisemail=lines_%readloop%

  SMTPSendMail>%thisemail%,post.mail.com,me,myname,subject,body,

  let>readloop=readloop+1
Until>readloop,lines_count
Hi,
I want to send one email to all users (all users in recipients field) not a separate email to each user. Is it possible ?

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Read emails from txt and add them to recipients

Post by Dorian (MJT support) » Mon Jan 16, 2023 9:22 am

Yes, this does that :

Code: Select all

readfile>d:\emails.txt,AllTxt
StringReplace>AllTxt,CRLF,;,EmailList
Let>SMTP_CCLIST=EmailList
SMTPSendMail>EmailList,%SMTPServer%,me,myname,Subject,Body,
You can also try SMTP_BCCLIST instead of SMTP_CCLIST. However, during my tests (Macro Scheduler 15.0.21) sending via Gmail I noticed this is CCing and not BCCing. Please let me know if you get similar results and I'll mention it to dev.

SMTPSendMail : To include CC or BCC email addresses set the SMTP_CCLIST and SMTP_BCCLIST variables. Separate multiple email address with semicolons.
Yes, we have a Custom Scripting Service. Message me or go here

Identis
Junior Coder
Posts: 26
Joined: Fri Mar 27, 2015 11:26 am

Re: Read emails from txt and add them to recipients

Post by Identis » Mon Jan 16, 2023 11:22 am

Dorian (MJT support) wrote:
Mon Jan 16, 2023 9:22 am
Yes, this does that :

Code: Select all

readfile>d:\emails.txt,AllTxt
StringReplace>AllTxt,CRLF,;,EmailList
Let>SMTP_CCLIST=EmailList
SMTPSendMail>EmailList,%SMTPServer%,me,myname,Subject,Body,
You can also try SMTP_BCCLIST instead of SMTP_CCLIST. However, during my tests (Macro Scheduler 15.0.21) sending via Gmail I noticed this is CCing and not BCCing. Please let me know if you get similar results and I'll mention it to dev.

SMTPSendMail : To include CC or BCC email addresses set the SMTP_CCLIST and SMTP_BCCLIST variables. Separate multiple email address with semicolons.
Thank you!!!
For me everything ok with SMTP_BCCLIST, but I'm sending not via gmail.

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Read emails from txt and add them to recipients

Post by Dorian (MJT support) » Mon Jan 16, 2023 11:39 am

Aah, that's good to know. Many thanks.
Yes, we have a Custom Scripting Service. Message me or go here

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts