Skip to Content
0
Former Member
Aug 19, 2014 at 01:17 PM

Send HTML email from C4C?

755 Views

Hello Experts,

We are trying to email from the Event-BeforeSave of our BusinessPartner extension object. Emailing seems to work just fine (plain text or PDF attachment), until the moment we add HTML content.

This is the code that we currently are using:

// create email activity
  elEmailRoot.Name.content = "Test HTML"; 
  instEmail = EmailActivity.Create(elEmailRoot); 

  // add receiver
  elEmailParty.PartyKey.PartyID.content = "<myemail>";
  instEmail.MessageToParty.Create(elEmailParty); 

  //Create att folder
  instEmailAttFld = instEmail.AttachmentFolder.Create();

  //Add attachment (html body)
  docName = "body.html";
  doctype.content = "10001";
  binaryObject.mimeCode = "text/html";
  //binaryObject.content = Binary.ParseFromString( resultData.GetFirst().EmailTemplate );
  binaryObject.content = Binary.ParseFromString("<html><head></head><body><div>test</div></body></html>");
  instEmailAttFld.CreateFile(doctype, docName, docAltName, docDesc, binaryObject);

  // send email
  instEmail.Send();

Is there an error within my code or is it possible that the system is blocking HTML email? Thanks for your help!