muquit / mailsend

A program to send mail via SMTP from command line
Other
294 stars 68 forks source link

How to attach unknown files #88

Open SebastianZitzl opened 8 years ago

SebastianZitzl commented 8 years ago

Hi,

i´m new to mailsend and i want to attach a file, which has an individual name every time it is created. I tried * and *.extension but nothing worked. Can you help me?

@echo off

mailsend.exe -to xyz@googlemail.com -from user@domain.top -ssl -port 465 -auth -smtp >smtp.domain.top ^ -sub Subject -user user@domain.top -pass password -attach "C:\test\Inbox*.pdf"

Pause

Thank you.

muquit commented 8 years ago

mailsend itself does not support wildcard yet. You've to write a script to figure out the filename and call mailsend.

Thanks.

SebastianZitzl commented 8 years ago

Thank you, here´s my working code:

@echo off

for /f %%i in ('dir /b /s /a-d "Path_to_file*.tif"') do set "filevariable=%%~ni"

mailsend.exe -to xyz@domain.com -cc xyz@domain.com -from zyx@domain.com -ssl -port 465 -auth -smtp smtp.domain.com -sub Subject -user zyx@domain.com -pass password -attach >"Path_to_file\%filevariable%.tif"