Skip to Content
0

SAP C4C Send Email by Custom Button

Jun 23, 2017 at 06:54 AM

256

avatar image

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!!

sendemail.png (155.2 kB)
sendmail.png (36.7 kB)
sendmaile2.png (67.6 kB)
sendmail3.png (24.7 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Zoran Galijanic Jun 23, 2017 at 12:07 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Zoran,

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

0
Zoran Galijanic Jun 26, 2017 at 11:10 AM
0

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 :-)

Show 2 Share
10 |10000 characters needed characters left characters exceeded

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(); 

0

Hi,

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

br,

Zoran

0