cancel
Showing results for 
Search instead for 
Did you mean: 

Send HTML email from C4C?

Former Member
0 Kudos

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!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi R,

Pleas check this link..

Many Thanks,

Mithun

Former Member
0 Kudos

Hi Mithun,

I already found that and tried removing the HTML like proposed in that topic. Problem is, we would like to send a HTML email.

Thanks!

Roelof

Former Member
0 Kudos

Hi Albers,

unfortunately sometimes the backend antivirus system blocks html email. we can't do anything about it. Let's wait for next releases.

Former Member
0 Kudos

Hi Alessandro,

I can confirm that with SDK 1408 the following code works:


  elActivityRoot.TypeCode = "39"; // create Email

  elActivityRoot.SubjectName = "Subject";

  instActivity = Activity.Create(elActivityRoot);

  elActivityParty.PartyName = "test@email.com";

  instActivity.MessageToParty.Create(elActivityParty);

  // Create a text of type "Body Text"

  instActivityAttachm = instActivity.AttachmentFolder.Create();

  elActivityAttachmDoc.VisibleIndicator = true;

  elActivityAttachmDoc.MIMECode = "text/html";

  elActivityAttachmDoc.Name = "body.html";

  elActivityAttachmDoc.AlternativeName = "body.html";

  elActivityAttachmDoc.CategoryCode = "2";

  elActivityAttachmDoc.TypeCode.content = "10001";

  instActivityAttachm.Document.Create(elActivityAttachmDoc);

  var bin = Binary.ParseFromString( "<html><head></head><body><div>test <strong>HTML</strong>mail</div></body></html>" );

  var doc = instActivityAttachm.Document.GetFirst();

  var filecontent = doc.FileContent.Create();

  filecontent.BinaryObject.content = bin;

  instActivity.Send();


Thanks for your input!

Jacques-Antoine
Active Participant
0 Kudos

Hello M. Albers,

Do you already have access to the 1408 sdk?

I personally cannot find a download file in the download center.

Thank you for your attention.

Regards.

Jacques-Antoine

Former Member
0 Kudos

Hi R. Albers,

We have a requirement to provide a button in Appointments and on click of it an email has to be sent out to all the parties involved. For this, we have created a custom BO with a send email action. This action contains the code exactly the same as quoted here. Also, the studio version is 1408. But when the execution reaches instActivity.Send() statement, a dump is being raised. The custom BO binding to the Activity BO is working fine.

We also tried explicitly mentioning a personal gmail email ID but in vain. Any suggestions where we might be wrong ?

Any help will be highly appreciated. Thanks.

Regards

Shruti

Former Member
0 Kudos

Hi, you can't create an activity from an activity (also if they are different type like appointment and email).

You are inside an appointment and you are trying to create an email activity.

To solve the problem you need to create a webservice and to call this WS from your session. It will create a completely new detached session and it will work.

Regards

Former Member
0 Kudos

Hi Alessandro,

Thank you for your valuable response.

I downloaded the email activity inbound WSDL from communication arrangements and tried creating an external web service definition for this WSDL but failed. It gives me the following error:

The further plan after creating the external WS definition was to call its create method from my session.

Can you please suggest where am I going wrong ? and also provide me with some detailed insight into this issue ?


Regards

Shruti

Former Member
0 Kudos

Hi,

can you please provide details and screenshots about the inbound WS definition?

Answers (0)