Hello,
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;
contactEntity.SetContactId(companyId);
NSPerson personEntity;
personEntity.SetPersonId(personId);
NSDocumentAgent documentAgent;
NSDocumentEntity documentEntity = documentAgent.CreateDefaultDocumentEntity();
String docName = getCurrentDateTime().toString() + emailSubject + ".msg";
docName = docName.substitute(" ", "--");
documentEntity.SetName(docName);
documentEntity.SetHeader(emailSubject);
documentEntity.SetContact(contactEntity);
documentEntity.SetPerson(personEntity);
documentEntity.SetDocumentTemplate(documentTemplate);
documentEntity.SetDate(getCurrentDateTime());
//documentEntity.SetCompleted(1);
documentEntity.SetAssociate(associate);
documentEntity = documentAgent.SaveDocumentEntity(documentEntity);
NSStream stream;
stream.SetStream(emailContent.toByteArray());
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.
Outlook:

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?
Thanks,
David