I've created a very simple package that loops through folders (and subfolders), retrieving a list of files that exist and compiling them into a variable called str_AllFiles. The ForEach loop does its thing, the script task to compile the string does its thing, and when it's all said and done the Send Mail task does its thing. Everything works just fine...except that the resultant email that's generated comes out as hyperlinks to the actual files instead of just directory/file names. The directory/file names are present, but they are all hyperlinks to the files themselves.
Is there any way to reformat the string variable or the Send Mail message source so that it's plain text? I've seen some suggestions to use a script task to send the email as HTML, but when using that (from here: http://microsoft-ssis.blogspot.com/2013/08/sending-mail-within-ssis-part-2-script.html), but I keep getting an exception error that I can't track down when coding this. To be fair, I'm hard-coding the FROM, TO, and SUBJECT when using the HTML version, which may very well be the issue here.
Any ideas on this? How do I transform the message source so that it's plain text and not a page of hyperlinks?
Related
I am trying to copy the source code of a 3rd party email provider I'm using to match their look and feel.
I am viewing the raw source, to format it I had to remove all the =\ns (the end value of a line because the raw source breaks it up), however I still can't seem to figure out what to do from there to copy the styling since I can't find a parser to correctly handle this email HTML. Any recommendations on formatting an email or just grabbing the styling of it?
PS: I'm using nodemailer for sending emails
It was a bit of a pain, but here are the steps in visual studio code:
Remove all =\n ("=" followed by new line)
rename to an .html file if you haven't instead of .eml
replace all instances of =3D" with ="
search for any more locations for 3D, delete each one you can
Now you have good html which just needs to be formatted, I recommend using a formatter like https://www.freeformatter.com/html-formatter.html
You now have your template, use templated strings to insert variables as needed. Use this for the html value of nodemailer
I have a form where I simultaneously send several (let's say 10) files to the backend, along with some other regular input fields.
When I find a validation problem in the backend I display the form again and fill the regular inputs (dropdowns, text inputs, etc.), but I cannot fill the file fields, forcing the user to select the files from the file directory again.
The solution I think of is sending the base64 encoded representation of the files, and put them back in the form in case there is a validation error, but I would like to know if there is a simpler way.
No matter what you do, you can not skip server-side validation. For security reasons (someone sending raw requests for example). As far as showing the files in case of error (or simple reloading) I would send it as Base64, but via AJAX if the files are large.
Client-side validation: most validations (if not all) can be done using plain JS. Be it filesize, content type... and more specific validations according to filetypes (image, document...)
Server-side validation: Once sent, fully validate the file and content.
Send files back:In case of error, send the files with the request if small. If big send them via AJAX to avoid blocking and keep page loading times fast.
Hope it helps!
The simplest thing to do would be :
1) Validate all fields on the client side (javascript/jquery)
2) Once all other inputs are validated, then you send in Files.
NB: If you need to validate some values on the server side, use ajax for both steps (1) and (2). Also, try to give a bit more details to get quality answers
I would create a temporary store for uploaded files and would send back only a unique-hard-to-guess ID got from the store instead than the whole file.
The form section for a single file upload would then include also an hidden input carrying the unique file-ID.
When processing the request: if there is a file in the request get the file (and store it if form not valid) otherwise if there is a file-ID get the file from store.
I'm trying to understand if it's possible to write to an xls file with a bash script. Situation is outlined below.
I have a cronjob that runs every monday and generates an xls and emails to my client. This xls is filled with data from a MySQL DB. when the report is empty and the client attempts to open it, it shows as corrupt. Originally I addressed this issue by excluding empty files from the email with an if statement. However, the constraint is that all 4 reports much reach the client - empty or not.
So my question is, can I simply add a row of text at the top with a bash script so the file never "empty"? I'm not an expert in bash scripting by any means, so feedback here would be great. thanks!
Tony
I'm not aware of any pure bash implementation for writing XLS files. There are solutions in other languages such as Perl, Python, or PHP. If you think outside the box there is another option available to you. You mentioned that you currently use an if statement to not attach empty files. Create a blank spreadsheet in a program like MS Excel, optionally enter some text in A1 like "No records", save it, and transfer that to a known location on the server that runs the cronjob. Rather that skipping the attachment, whenever you detect an empty file in your if statement just attach the blank "No records" template XLS file. You may need to copy the template to a temporary location before attaching if you need to rename the file.
I'm trying to store links to files uploaded with phpmailer in my MySQL database so that when a web page calls the record, the user can download the files.
My files were getting attached as I want before I added the anchor tag. Now they no longer get attached to the email, and only the file names are making it into the database. Am I missing something simple?
$mail->AddAttachment("<a href='/home/company/upload/'>".$_FILES['rfile']['name'][0]."</a>"); // add attachments
$mail->AddAttachment("<a href='/home/company/upload/'>".$_FILES['rfile']['name'][1]."</a>"); // add attachments
Why are you putting HTML into something that's expecting a path to a file? Do this instead (and pay attention to what Marc B said - you should be calling move_uploaded_file() somewhere.).
$mail->AddAttachment('/home/company/upload/'.$_FILES['rfile']['name'][0]);
$mail->AddAttachment('/home/company/upload/'.$_FILES['rfile']['name'][1]);
So I want to create a chart using Google Chart API. The problem is following:
I need to create a chart which would use JSON data for the Output.
Example:
I am creating a BarChart which should show Montly Income. Each bar should represent X value of income. But this income changes monthly and I dont want to update the new numbers (as there are plenty) manually by writting them inside the JSON structure (I will use PERL scripts that will gather the new data).
I have read plenty on ther web, but all are using JSON COMBINED WITH PHP ! But I do not have a Web Server. What I want is to create a JSON FOLDER on my desktop, which will contain 100 JSON files inside it.
And when I browse my HTML page, I will click on Monthly Income (May) and this should open a new HTML page which should have some sort of INCLUDE or call function, which should call a SPECIFIC JSON file from the JSON folder on my computer that is coresponded with the path I have chosen on my webpage (in this case Monthly income (May)).
I think my problem is MORE SIMPLE than the method with PHP updating, because I am not worried with the updates - I will update my text files with PERL script. I just need a way, how to include a JSON file into my HTML script, without using PHP or any of these WEB SERVER related stuff.
Any ideas / suggestion ?
Thanks,
David
You can't reliably do it cross-browser with JSON because some browsers block ajax calls from local files (e.g., file:// URLs). But you can do it with JSON-P.
You create the files like this:
dataCallback(/*...JSON here...*/)
E.g.:
dataCallback({
"foo": "bar"
});
...and use this to load the relevant:
<script>
function dataCallback(data) {
// Here, the data will be the deserialized (parsed) data
}
</script>
<script src="/path/to/jsonp/file"></script>
Basically this is using JavaScript, rather than JSON, but where the data file although technically code is really just a function call with the data in the argument.