Archiving email CRMScript


My goal is to archive an email i send using the Email class in CS as email in SuperOffice.

Currently i have the following code:

Void archiveEmailAsDocument(String emailSubject, String emailContent, Integer documentTemplateId, Integer companyId, Integer personId, Integer associateId)
  NSAssociateAgent associateAgent;
  NSAssociate associate = associateAgent.GetAssociate(associateId);
  NSListAgent listAgent;
  NSDocumentTemplate documentTemplate = listAgent.GetDocumentTemplate(documentTemplateId);

  NSContact contactEntity;

  NSPerson personEntity;

  NSDocumentAgent documentAgent;
  NSDocumentEntity documentEntity = documentAgent.CreateDefaultDocumentEntity();
  String docName = getCurrentDateTime().toString() + emailSubject + ".msg";
  docName = docName.substitute(" ", "--");
  documentEntity = documentAgent.SaveDocumentEntity(documentEntity);

  NSStream stream;

  documentAgent.SetDocumentStream(documentEntity, stream, true);


the code works fine, it save a appointment and document row, and a .msg file is created in the SO_ARC.

But outlook and the internal mailbox both show a error when trying to open the email in CRM.


Internal mailbox:

If i look in the .msg file the it does have the email content, looks like CRM doesn't see it as a valid email?

Is there a way to archive an CS email as valid email in CRM using CRMScript?




RE: Archiving email CRMScript

Anyone have an idea on how to solve this?

We keep getting the wish from customers that they want to automated sending specific emails, and have it archived in CRM.

Af: David Hollegien 15. maj 2018

RE: Archiving email CRMScript

Hi David,

could you solve the problem? We are currently facing a similar challenge and are looking for a solution.
It would be great if you could share your experiences with us.

Best regards


Af: Ulrich Klein 6. nov 2020

RE: Archiving email CRMScript

Hello Ulrich,

We eventually solved this by using an external program called by runProgram to generate an MSG and return that to CS. Obviously not the greatest solution and not 'online-proof', but better the nothing.

Since creating this solution the EmailAgent has been expanded with a lot more possbility, so maybe it is now possible to do it using CRMScript.

Af: David Hollegien 6. nov 2020