Batch file to email a file with an attachment




















This thread is locked. You can follow the question or vote as helpful, but you cannot reply to this thread. I have the same question 0. Report abuse. Details required :. Cancel Submit. I am currently using office and a bat file to invoke outlook to send attachments.

I would like to update to office or , but cannot until I can get the attachements working. I tried with and had to revert because it would NOT allow attachments. Ok, it's not arbitrary; RFC has the syntax:. But as long as it obeys the syntax above, for almost all practical purposes it's as if it's arbitrary modulo the recommendations contained in the RFC about unpredictability and all that.

There are a few implementations of "mail" or, more correctly these days, "mailx" , with slightly different syntax and capabilities. The version that can do attachments is heirloom-mailx. Since a sistem where mailx is installed should generally also have a "sendmail" binary, one may wonder why bother at all with "mail". Well, because it's simpler:. This version of mailx can also send using SMTP the man has all the details , so it does not necessarily need a local sendmail program:.

Here are some other tools that can send email with attachments, but are somewhat less commonly installed. Mutt can send emails both by invoking sendmail or by talking directly to a SMTP server.

To simplify things, some of the settings above can be saved in mutt's configuration file to avoid specifying them on the command line.

Another one is sendEmail , which is available packaged for many distibutions and apparently can only send through SMTP not sendmail :. Swaks is smart about guessing whether the option arguments it's given represent files or strings to take as-is where applicable , wihch is good because the same sintax does it all.

Metasend from metamail uses sendmail, needs body text in a file and explicit MIME types:. After the textual body part, each new file to attach is introduced by the -n switch, and for each file three pieces of informations are given: the file path with -f , its MIME type with -m , and the encoding with -e.

By default metasend would split the message into multiple parts, because it assumes that the receiver uses metamail which is able to reassemble them; since this is not always the case, the -S option can be used to specify a message size under which no split will be performed. Ideally, this has to be larger than the sum of all the encoded message parts. In the example it's just some big number, but it can be calculated more accurately. Furthermore, the body text must be in a file, and it's not possible to specify a sender address, so it seems to be the least powerful option:.

I have created below script to attached a CSV File. The File is getting generated, but its truncating the header row of CSV incorrectly and also there is one more file thats getting attached with the email, namely 'ATT Anything wrong that you could found out here?

Don't know whether that is the problem in your case, but it's something that definitely needs fixing. I'm using your "sendmail" section to create mails, but I have a problem with PDF docs attaching.

In fact, it's the base64 instruction that's not recognized by my Unix server. What does it mean that base64 is "not recognized"? If it's not installed, you'll have to install the package containing the program using your distribution's package manager. However it should be in the "coreutils" package at least in recent distributions , which is almost surely guaranteed to be installed on any system.

Perhaps your PATH does not include its location? Without more details on the error it's impossible to tell. You can also refer to specific arguments by their position:.

You can also put logic in the batch script so it too has arguments you can pass sensitive values to it at execution time, and use argument placeholders rather than hard-coding sensitive values. This way if the scripts are opened, the sensitive values you need to protect will not be exposed or hard-coded into the script logic for anyone to see who may have read access to the script. Here's an all-in-one dynamic batch script that you just pass the Gmail account username, the Gmail account password, and the full path to the attachment.

This means that you will want to be sure you copy this script and then run the copy only from the machine s you'll execute where you don't want this information exposed. Send Method. In addition, substitution of FOR variable references has been enhanced. You can now use the following optional syntax:. Sign up to join this community.

The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. Send a file to an email address using a bat file without exposing the email info? Ask Question. Asked 3 years, 3 months ago. Active 10 months ago. Viewed 32k times. Logic such as: check if the internet is working properly if ok send the file and then remove the bat file check if the internet is working properly if no Schedule it to do it later or add it to the start up when done remove it from the Schedule or the start up!



0コメント

  • 1000 / 1000