Page 1 of 1

Email form report attachment

PostPosted: Tue Jul 31, 2018 6:21 pm
by Riyaz
Hi There

We have a requirement wherein we place an email button on the ribbon of the warehouse transfer out form which initiates the JiwaApplication.JiwaEmailUI.MainForm to send an email. We have written a plugin for this at the moment, which works fine, just wanted to know if we can attach a Jiwa Report to the email on the fly, so basically its a warehouse transfer report which gets generated depending on the tranfer no it originated from.

Thanks

Re: Email form report attachment  Topic is solved

PostPosted: Tue Jul 31, 2018 6:25 pm
by Mike.Sheen
Riyaz wrote: just wanted to know if we can attach a Jiwa Report to the email on the fly, so basically its a warehouse transfer report which gets generated depending on the tranfer no it originated from.


Hi Riyaz,

Yes - the Email Message object has an attachments collection which is just our normal documents collection. You can add a report to that. For an example of how to generate a PDF and save it to disk, see this topic - you essentially want to do exactly that and then add the file to the Attachments property of the Email Message.

Mike

Re: Email form report attachment

PostPosted: Tue Jul 31, 2018 6:47 pm
by Riyaz
Hi Mike

Thanks for the quick reply, am sure that'll do the job, got a question though, can we save the PDF withing jiwa temp folders and then retrieve it, rather than a local drive path or network path.

Thanks
Riyaz

Re: Email form report attachment

PostPosted: Tue Jul 31, 2018 7:21 pm
by Mike.Sheen
Riyaz wrote:can we save the PDF withing jiwa temp folders and then retrieve it, rather than a local drive path or network path.


Yes - the topic I linked shows how to do that in my first reply:

Code: Select all
     // export report to PDF
      string tempFolderPath = System.IO.Path.GetTempPath();
      string fileName = report.Title;

      // Make filename safe
      foreach (char c in System.IO.Path.GetInvalidFileNameChars())
      {
         fileName = fileName.Replace(c.ToString(), "");
      }

      string fullFileName = System.IO.Path.Combine(tempFolderPath, fileName) + ".pdf";


Mike