cancel
Showing results for 
Search instead for 
Did you mean: 

SAP C4C Send Email by Custom Button

Former Member
0 Kudos

Hello ,

In 1705,I had met a question : I use SDK example code(as picture show) to send a email in an action.absl(as picture show)

I have done some business configuration and master data but when I clicked the button to send email I didn't receive the email at the same time I didn't received error messages.

Did I leave out any configuration,I have maintained employees' mail address?

(In addition, I debugged my action.absl and the codes can run completed)

So,I don't know what is wrong with my operation ,can anyone give me some advices?

Thanks in advance very much!!

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member422907
Contributor
0 Kudos

Ok, the second problem is that "MessageFromParty" HAS TO BE valid employee from your system (please check if

121503253@qq.com is associated to valid employee in your system, btw. "MessageFromParty" will be populated automatically from your session, see bellow in the code snippet)

Hint 1: don't forget to press save button on your business object where you execute this part of code.

Hint 2: don't forget to provide user access rights to Activities work center for user that is sending this mail

Result: email has to arrive on valid mailbox, and activity entry type email has to be visible on Activities work center.

import ABSL;
import AP.PC.ActivityManagement.Global; 
var elActivityRoot					:elementsofActivity;
var instActivity;
var elActivityParty					:elementsofActivity.Party;
// Activity: define text collection
var elActivityTxtCollTxt:      elementsofActivity.TextCollection.Text;
var elActivityTxtCollTxtCntnt: elementsofActivity.TextCollection.Text.TextContent;
var instActivityTxtColl;
var instActivityTxtCollTxt;
elActivityRoot.TypeCode="39";
elActivityRoot.SubjectName="Test from ABSL code 0001";
instActivity = Activity.Create(elActivityRoot);
//MessageFromParty will be automatically set from your session but if from some reason is not set then you have to set/change it by yourself with REAL employee name from your system
if (! instActivity.MessageFromParty.IsSet()) {
//real employee from your system defined by ID, Name or Email:
elActivityParty.PartyName = "FirstName LastName"; 
instActivity.MessageFromParty.Create(elActivityParty);
	}
//MessageFromParty will be automatically set from your session but if from some reason is not set then you have to set/change it by yourself with REAL employee name from your system
if (! instActivity.EmployeeResponsibleParty.IsSet()) {
//real employee from your system defined by ID, Name or Email:
elActivityParty.PartyName = "FirstName LastName"; 
instActivity.EmployeeResponsibleParty.Create(elActivityParty);
	}
//message sent to
elActivityParty.PartyName = "XXXXXXX@gmail.com";
instActivity.MessageToParty.Create(elActivityParty);
//Assotiation to Contact
elActivityParty.PartyName = "CONTACT NAME FROM CONTACT BO.";
instActivity.ContactParty.Create(elActivityParty);
//Assotiation to Account
elActivityParty.PartyName = "ACCOUNT NAME FROM ACCOUNT BO";
instActivity.ActivityParty.Create (elActivityParty);
// Create a text of type "Body Text"
instActivityTxtColl = instActivity.TextCollection.Create();
elActivityTxtCollTxt.TypeCode.content = "10002";
instActivityTxtCollTxt = instActivityTxtColl.Text.Create(elActivityTxtCollTxt);
elActivityTxtCollTxtCntnt.Text.content = "Body text of the Activity Email";
instActivityTxtCollTxt.TextContent.Create(elActivityTxtCollTxtCntnt);
//send message
instActivity.Send();

Please use following code snippet and mark this answer correct if you accept this 🙂

Former Member
0 Kudos

Hi Zoran,

I appreciate to receive such a detailed answer from you.

And It works when I use your code and replace employee in the appropriate location,it's very useful.

But now,I have another problem: I add some code(from Repository Explorer example code) and want to create attachment in the email (as the code snippet show),but it didn't work(I can receive the email without the attachment).

Could you please take a look at it?

Thanks very much!

 // Create a text of type "Body Text"
instActivityTxtColl = instActivity.TextCollection.Create();
elActivityTxtCollTxt.TypeCode.content = "10002";
instActivityTxtCollTxt = instActivityTxtColl.Text.Create(elActivityTxtCollTxt);
elActivityTxtCollTxtCntnt.Text.content = "Body text of the Activity Email";
instActivityTxtCollTxt.TextContent.Create(elActivityTxtCollTxtCntnt);
// Create an attachment of type "Link"-----------------------Add by me to create an attachment
// Activity: define attachment folder
var elActivityAttachmDoc:      elementsof Activity.AttachmentFolder.Document;
var instActivityAttachm;
instActivityAttachm = instActivity.AttachmentFolder.Create();
elActivityAttachmDoc.Description.content = "PDI Comment for Attachment";
elActivityAttachmDoc.CategoryCode = "3"; 
elActivityAttachmDoc.Name = "SAP";
elActivityAttachmDoc.AlternativeName = "SAP Homepage";
elActivityAttachmDoc.ExternalLinkWebURI = "http://www.sap.com";
instActivityAttachm.Document.Create(elActivityAttachmDoc);
/nd message-----------------------------------------------End add
instActivity.Send(); 

former_member422907
Contributor
0 Kudos

Hi,

I don't know your business need, but you can incorporate link into email body.

br,

Zoran

former_member422907
Contributor
0 Kudos

Hi,

I think problem might be, that your all mail is delivered into 653237091@qq.com mailbox. Does this mail exist at all?

br,

Zoran

Former Member
0 Kudos

Hi Zoran,

I cancel the delivery email address,still failed to send.