Hi,
I am sending an email from SuperOffice via a CRM Script (pretty basic code below, but in my full code I am also using reply templates, and the parser variables).
//Send Email
Email email;
email.setValue("to", toEmailAddress);
email.setValue("subject", subject);
email.setValue("bodyHtml", bodyHtml);
email.send();
I now want to archive that email in SuperOffice, so that it looks like a standard SuperOffice archived email, I.E. I can see values in the email to field, email subject, and email body.
At this point, I cannot even seem to set the email body, with the code I have below not working (based on the AI results produced from SuperOffice Docs).
NSDocumentAgent agent;
NSDocumentEntity doc = agent.CreateDefaultDocumentEntity();
// set properties (name, contact, etc.) on doc
//Set Document Template
NSDocumentTemplate docTmpl;
docTmpl.SetDocumentTemplateId(154);
doc.SetDocumentTemplate(docTmpl);
//Set Document Heading
doc.SetHeader("Demo");
//Set Document Filename
doc.SetName("POC " + getCurrentDateTime().toString("YY2MM2DD2HH24MI2SS2") + ".somail");
//Save Document
doc = agent.SaveDocumentEntity(doc);
NSStream stream;
stream.SetStream(bodyHtml.toByteArray());
doc = agent.SetDocumentStream(doc, stream, true);
The code does not error when I run it, but I do then get an error when trying to open the archived email that the CRMScript has created. I haven't even got to the point of looking to set the email to address and subject.
Is it possible to archive an email via CRMScript that was created using the Email agent?
Many thanks,
Trevor
Alle Svar (2)
Hi Tony,
Not possible today by anything build-in, the EmailAgent isn't accessible from CRMScript/External apps, and CRMScript does not have any build in way to get a valid rfc822/eml formatted variant of the e-mail message you sent using the email class.
If you can add a BCC receipient to your email, and that mail would end up in a dedicated mailbox, then DataBridge is able to pick up that email and archive it in SuperOffice as EML. It can pick details from the To/CC/From or the subject or body of the email to archive it to the relevant company, contact, project and sale.
Hope this helps. Let me know if you need some guidance on how to do that or for demo access to DataBridge.