send mail to address book

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
daxxx2706
Posts: 4
Joined: 19 Jan 2015 07:39

send mail to address book

#1 Post by daxxx2706 » 19 Jan 2015 07:47

Hello everyone, I'm new on the program in cmd. I want to make a script that having x pdf files, each of which consists of "CODE + File Name", the program needs to see in a txt file that CODE is associated with which email address, so you can send an email to that address with that attachment :roll:
Thank you!

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: send mail to address book

#2 Post by Squashman » 19 Jan 2015 09:28

Please be more specific and provide examples.
Please read this thread as well.
viewtopic.php?f=3&t=6108

daxxx2706
Posts: 4
Joined: 19 Jan 2015 07:39

Re: send mail to address book

#3 Post by daxxx2706 » 19 Jan 2015 09:47

Squashman wrote:Please be more specific and provide examples.
Please read this thread as well.
viewtopic.php?f=3&t=6108


in a folder there are pdf files named like this:
DOCUMENT_XXXXXXXXXX_PIPPO_YYYYMMDD
where xxx is the user code of the recipient who will receive the document (unique)
Pippo is the name of the user (non-unique)
and then the date
"DOCUMENT" is constant in all pdf

I have another file "address", a csv, in which I have in the first column the code XXXXX, in the second column of the email address.

I have to send an email to the user XXXXX to your email address using blat

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: send mail to address book

#4 Post by Squashman » 19 Jan 2015 10:27

daxxx2706 wrote:I have to send an email to the user XXXXX to your email address using blat

I assume you mean: I have to send an email to user XXXXX using blat.
Does the PDF document need to be attached?
Could you please post the code that you use to send a single email using blat and show where the variables would go into the the command.

daxxx2706
Posts: 4
Joined: 19 Jan 2015 07:39

Re: send mail to address book

#5 Post by daxxx2706 » 19 Jan 2015 10:39

Squashman wrote:
daxxx2706 wrote:I have to send an email to the user XXXXX to your email address using blat

I assume you mean: I have to send an email to user XXXXX using blat.
Does the PDF document need to be attached?
Could you please post the code that you use to send a single email using blat and show where the variables would go into the the command.


This is an exaple for send to "mailto@contoso.com" from "emailsender (sender@domain.com)", an email with subject "your pdf is here" and attacched the file pdftosend.pdf

Code: Select all

blat.exe C:\Script\pdftosend.pdf -to mailto@contoso.com -server 10.0.0.1 -f "emailsender<sender@domain.com>" -subject "Your pdf is here"

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: send mail to address book

#6 Post by Squashman » 19 Jan 2015 16:49

Untested.
Remove the ECHO before the BLAT.exe command if you are satisfied with the output on the screen.

Code: Select all

@echo off
FOR %%G IN (C:\script\*.pdf) DO (
   FOR /F "tokens=2 delims=_" %%H IN ("%%~nG") DO (
      FOR /F "tokens=1,2" delims=," %%I IN (c:\script\address.csv) DO (
         IF /I "%%~H"=="%%~I" (
            echo blat.exe "%%~G" -to %%~J -server 10.0.0.1 -f "emailsender<sender@domain.com>" -subject "Your pdf is here"
         )
      )
   )
)
pause

daxxx2706
Posts: 4
Joined: 19 Jan 2015 07:39

Re: send mail to address book

#7 Post by daxxx2706 » 20 Jan 2015 01:24

Squashman wrote:Untested.
Remove the ECHO before the BLAT.exe command if you are satisfied with the output on the screen.

Code: Select all

@echo off
FOR %%G IN (C:\script\*.pdf) DO (
   FOR /F "tokens=2 delims=_" %%H IN ("%%~nG") DO (
      FOR /F "tokens=1,2" delims=," %%I IN (c:\script\address.csv) DO (
         IF /I "%%~H"=="%%~I" (
            echo blat.exe "%%~G" -to %%~J -server 10.0.0.1 -f "emailsender<sender@domain.com>" -subject "Your pdf is here"
         )
      )
   )
)
pause

Yeah it works very well, thank you! :wink:

Post Reply