CMDBuild Forum

Attach report to a workflow email

Hi,

Does anyone have an example on how to attach a report to a mail on a workflow script ?

Regards,

Oli

You can use the manageEmail widget (Workflow Manual, page 38) or the NewMail API (Workflow Manual, page 53).

CMDBuild Team

I'm trying to use the NewMail API but unsuccessfully
here's the script from the task:
 
newReport = cmdb.createReport("test Report","pdf").download();
/* Report is created under ${tomcat}/tmp */
 
cmdb.newMail()
  .withFrom(xxxx@xxx.com")
  .withTo(yyyy@xxx.com")
  .withSubject("Report Attached ")
  .withContent("Mail content ")
  .withAttachment(newReport)
  .send();
 
The question is how do I define through the API the report path ?
I tried newReport.getReportFullURL() or cmdb.getReportFullURL(newReport)
none of them work.
 
Regards
Olivier
 
Previously Tecnoteca wrote:

You can use the manageEmail widget (Workflow Manual, page 38) or the NewMail API (Workflow Manual, page 53).

CMDBuild Team

 

Hi, I solved the problem:
There is a mystyping on workflow doc page 44  on DownloadedReport.
The method for grabbing the report URL is getUrl() instead of getURL as mentionned in the doc.
 
 
Olivier
Previously Tecnoteca wrote:

You can use the manageEmail widget (Workflow Manual, page 38) or the NewMail API (Workflow Manual, page 53).

CMDBuild Team

 

Thanks for your reporting, we will update the manual
CMDBuild Team

I still have trouble using the NewMail object with the message : 

Error in method invocation: Method withAttachment( java.lang.String ) not found in class'org.cmdbuild.common.mail.DefaultNewMail
 
Here's the simple piece of code
 
Email = xxx@yyyy.com";
 
Datum=Calendar.getInstance();
FlowStatus = cmdb.selectLookupByCode("FlowStatus", "open.running");
 
newReport=cmdb.createReport("test 1NA","pdf").download();
 
cmdb.newMail()
.withFrom(cmdbuild@oxya.com")
.withTo(Email)
.withSubject("Mail subject " + Datum.getTime().toString())
.withContent("Mail content")
.withAttachment(newReport.getUrl())
.send();
 
 
 
 
 
Previously Tecnoteca wrote:
Thanks for your reporting, we will update the manual
CMDBuild Team
Hi,
Can't figure out where the error is !
I tried to parse the source code for the withAttachement() method but it is defined correctly.
Tried to update my libs both in shark and cmdbuild webapps (using 2.1.4) but still stuck at this point
 
anybody tried to send report through workflow ?
no script example, really ?
 
Regards,
Oli
Previously Oli wrote:
I still have trouble using the NewMail object with the message : 
Error in method invocation: Method withAttachment( java.lang.String ) not found in class'org.cmdbuild.common.mail.DefaultNewMail
 
Here's the simple piece of code
 
Email = xxx@yyyy.com";
 
Datum=Calendar.getInstance();
FlowStatus = cmdb.selectLookupByCode("FlowStatus", "open.running");
 
newReport=cmdb.createReport("test 1NA","pdf").download();
 
cmdb.newMail()
.withFrom(cmdbuild@oxya.com")
.withTo(Email)
.withSubject("Mail subject " + Datum.getTime().toString())
.withContent("Mail content")
.withAttachment(newReport.getUrl())
.send();
 
 
 
 
 
Previously Tecnoteca wrote:
Thanks for your reporting, we will update the manual
CMDBuild Team

 

The .getUrl() method of the DownloadedReport object returns a String (not a URL). So you have to create a new URL object and then use it into to the .withAttachment() method in this way:

 

reportURL = new URL(newReport.getURL());

cmdb.newMail()

      ...

      .withAttachment(reportURL)

      ...

      .send();

 

Best regards

      CMDBuild Team

 

 

Previously Oli wrote:
Hi,
Can't figure out where the error is !
I tried to parse the source code for the withAttachement() method but it is defined correctly.
Tried to update my libs both in shark and cmdbuild webapps (using 2.1.4) but still stuck at this point
 
anybody tried to send report through workflow ?
no script example, really ?
 
Regards,
Oli
Previously Oli wrote:
I still have trouble using the NewMail object with the message : 
Error in method invocation: Method withAttachment( java.lang.String ) not found in class'org.cmdbuild.common.mail.DefaultNewMail
 
Here's the simple piece of code
 
Email = xxx@yyyy.com";
 
Datum=Calendar.getInstance();
FlowStatus = cmdb.selectLookupByCode("FlowStatus", "open.running");
 
newReport=cmdb.createReport("test 1NA","pdf").download();
 
cmdb.newMail()
.withFrom(cmdbuild@oxya.com")
.withTo(Email)
.withSubject("Mail subject " + Datum.getTime().toString())
.withContent("Mail content")
.withAttachment(newReport.getUrl())
.send();

 

That's fine !
Many thanks to the team 
 
Oli
 
Previously Tecnoteca wrote:

The .getUrl() method of the DownloadedReport object returns a String (not a URL). So you have to create a new URL object and then use it into to the .withAttachment() method in this way:

 

reportURL = new URL(newReport.getURL());

cmdb.newMail()

      ...

      .withAttachment(reportURL)

      ...

      .send();

 

Best regards

      CMDBuild Team

 

 

Previously Oli wrote:
Hi,
Can't figure out where the error is !
I tried to parse the source code for the withAttachement() method but it is defined correctly.
Tried to update my libs both in shark and cmdbuild webapps (using 2.1.4) but still stuck at this point
 
anybody tried to send report through workflow ?
no script example, really ?
 
Regards,
Oli
Previously Oli wrote:
I still have trouble using the NewMail object with the message : 
Error in method invocation: Method withAttachment( java.lang.String ) not found in class'org.cmdbuild.common.mail.DefaultNewMail
 
Here's the simple piece of code
 
Email = xxx@yyyy.com";
 
Datum=Calendar.getInstance();
FlowStatus = cmdb.selectLookupByCode("FlowStatus", "open.running");
 
newReport=cmdb.createReport("test 1NA","pdf").download();
 
cmdb.newMail()
.withFrom(cmdbuild@oxya.com")
.withTo(Email)
.withSubject("Mail subject " + Datum.getTime().toString())
.withContent("Mail content")
.withAttachment(newReport.getUrl())
.send();