How to attach xls files to email when sending from rails, and not getting the attachment corrupt? - ruby-on-rails-3

If I attach xls files as attachment in the mailer like this
attachments["1.xls"] = File.read "1.xls"
If I try open the attachment from the received mail, Excel is unable to open and it says the file is corrupted.
Please let me know if I am missing something?
Please let me know if additional information is needed?

Found the answer here http://www.dixis.com/?paged=3
Apparently The correct way to attach binary files on Windows is
attachments[file_name] = File.open(file_location, 'rb'){|f| f.read}

Related

Corrupted PDF attachment on SOST tcode

I am sending email using cl_bcs class as PDF attachment.Now, when I do issue output to in VA02/03 tcode,it works and in email I can open the attachment.But,on press of save in change mode in va02 tcode,as output type is automatically triggered using condition record,it sends the mail but the PDF attachment(which is adobe form only) shows corrupted.
Any pointers?
Thanks for all your help.I found out the solution. The reason was that the pdf from Adobe Form FM was not generating correctly.So before converting to Binary, we need to pass docparams-getpdf = X.This solved the issue and attachment is opening like charm.I am using cl_bcs class for mail functionality.

compose email using default email program

I am trying to find some vb.net code to compose email using default email client, WITH attachment (a pdf file on my disk)
I tried
Process.Start("mailto:test#email.com?subject= &body=" & System.Uri.EscapeDataString("ABC"))
But it did not open the default program and also do not know how to attach a file.
Can someone kindly help me?
Best regards,
Furqan

Outlook - save/convert email body to PDF

I need a macro script to:
Convert/Print email body to PDF file
Save that file to a folder
Delete the email after
I'm pretty clueless on using scripts/macros on outlook. Would need step by step process if possible. I do have adobe program for converting installed.
You can save the message as a DOC file (OlSaveAsType.olDoc), then use the Word Object Model to convert it to PDF.

adobe reader could not open pdf because it is either not a supported file type or because the file has been damaged

I am using iTextSharp for creating PDF for reports & send as attachment(). Pdf is created successfully & can be opened locally using Adobe Reader but can't opened after sent to mail & gives error :
"adobe reader could not open pdf because it is either not a supported file type or because the file has been damaged "
Also pdf file size is zero in attachement.
I think its corrupted in between. what's may be the issue?
Problem was with Network Security(smtp permissions) rather any programming challenge. Got permissions for SMTP & configure it. Bingo, it's working.
The problem I had with the export to PDF format, was that my file was that I had some bad HTML tags closed, please check.

generating an html attachment vb.net

I am trying to generate a report html file and email it as an attachment with vb.net
I know how send mail and attachments.
Do I need to generate the html file, save it as an .html file to the local disk where the program runs, then add its file path to the attachment property to send it to the recipient?
It is going to be a rather large report, and I would like to send it as an attachment instead of directly inside of the email itself.
Thanks
Yes, you save the file to disk ant then add to the Attactments collection of the MailMessage. Here is the C# syntax to create an Attachment from a file on disk and add the attachment to the message. It will be similar for VB.Net.
Attachment att = new Attachment(filename);
message.Attachments.Add(att);