cancel
Showing results for 
Search instead for 
Did you mean: 

Send an existing attachment of AR Invoice as an email attachment using SDK / DI API

rajesh_khater
Active Participant
121

I have the following scenario:

User creates AR Invoice manually and adds a few attachments manually.

I have added a button in AR Invoice screen. On button click, the 1st attachment entry of the current AR Invoice should go as an email to the Business Partner.

I have seen a few examples, but some examples show how to send an Internal Message to another SAP user, while some other examples are not clear.

The button click should send an email with the following requirements:

1. The email should have a message subject and a message body

2. The email should have an attachment, and this should be the 1st attachment which is already attached to the current AR Invoice

3. The email should go to an external Business Partner's email id.

4. The email should be sent using the SBO Mailer.

I am again emphasizing that the attachment is already attached to the AR Invoice, and hence available in the configured Attachments folder, and so I need not save the file again in the Attachments folder.

Requesting SAP support team and other experts to answer with a specific example, and not point to a general link which contains half the details.

I just have a basic idea that I have to use the MessagesService object, but there is no example in the DI API Reference help file regarding sending email with attachment. Unfortunately SAP's DI API Reference help file is very poorly documented, otherwise I would not be asking this question here.

I have gone through this blog: https://blogs.sap.com/2009/10/07/how-to-send-an-email-with-attachment-via-the-di-api/

It mentions that the oMessages object is deprecated and we must use the oMessageService. It shows an example using the oAttachments2 object, which is not relevant in my case as the Attachment already exists in AR Invoice. Then it proceeds to show how to send an Internal Message to another SAP user, where as the title of the blog is: How to send an Email with attachment via the DI API.

I will really appreciate a useful code example.

Thanks in advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

rajesh_khater
Active Participant
0 Kudos

Please ignore this question. I am unable to delete this question.

I have posted the revised and correct question at: https://answers.sap.com/questions/13947901/send-the-1st-attachment-of-ar-invoice-as-an-email.html