Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Send e-Mails with attached MIME-Objects from Repository

Former Member
0 Kudos

Hi everyone!

Does someone know a solution to send e-Mails with attached MIME-Objects from MIME-Repository?

At the moment I'm using the class CL_BCS to send mail with works fine. Now I just want to attach (or even better embed!) for example one or more icons from the MIME-Repository to this mail.

Thanks in advance!

Message was edited by: Marc Glässer

1 ACCEPTED SOLUTION

athavanraja
Active Contributor
0 Kudos

Welcome to SDN

if you just want it as a image in the body of the mail, just send the image link as a html content in the body of the mail. (this has other problem, when openning the mail the system would require authentication into WAS system)

to send it as a attachment

1. read the mime

DATA: binary_content TYPE solix_tab.

data: o_mr_api type ref to if_mr_api.

if o_mr_api is initial.

o_mr_api = cl_mime_repository_api=>if_mr_api~get_api( ).

endif.

call method o_mr_api->get

exporting

i_url = l_url

importing

e_is_folder = is_folder

e_content = l_current

e_loio = l_loio

exceptions

parameter_missing = 1

error_occured = 2

not_found = 3

permission_failure = 4

others = 5.

l_current will hold the image in a XSTRING var

convert the xstring to binary table

REFRESH binary_content .

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

EXPORTING

buffer = l_current

TABLES

binary_tab = binary_content.

CALL METHOD document->add_attachment

EXPORTING

i_attachment_type = 'GIF' " pass the right mime type

i_attachment_subject = atta_sub

i_att_content_hex = binary_content.

Hope this helps.

Regards

Raja

5 REPLIES 5

athavanraja
Active Contributor
0 Kudos

Welcome to SDN

if you just want it as a image in the body of the mail, just send the image link as a html content in the body of the mail. (this has other problem, when openning the mail the system would require authentication into WAS system)

to send it as a attachment

1. read the mime

DATA: binary_content TYPE solix_tab.

data: o_mr_api type ref to if_mr_api.

if o_mr_api is initial.

o_mr_api = cl_mime_repository_api=>if_mr_api~get_api( ).

endif.

call method o_mr_api->get

exporting

i_url = l_url

importing

e_is_folder = is_folder

e_content = l_current

e_loio = l_loio

exceptions

parameter_missing = 1

error_occured = 2

not_found = 3

permission_failure = 4

others = 5.

l_current will hold the image in a XSTRING var

convert the xstring to binary table

REFRESH binary_content .

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

EXPORTING

buffer = l_current

TABLES

binary_tab = binary_content.

CALL METHOD document->add_attachment

EXPORTING

i_attachment_type = 'GIF' " pass the right mime type

i_attachment_subject = atta_sub

i_att_content_hex = binary_content.

Hope this helps.

Regards

Raja

0 Kudos

Hi Raja,

thanks for the fast response and the welcome greets.

The solution with sending a link as a html content in the body of the mail is out of the question because of the authentication issue).

I'm not so familiar with the MIME-Repository and it's programming interfaces. So could you please somehow explain me how to attach for example a GIF-File from MIME-Repository with the filename "s_s_keyi.gif", logical ID "6B1679466E47604D82A22F06C8953F7D" and physical ID "412181A9DBF65915E10000000A1145AB"?

Your example showed a possibility with attaching the document by URL. What is the URL of the above "s_s_keyi.gif"?

0 Kudos

no need for the logical id or the physical id.

(how did you get them?)

can you get the path of the image s_s_keyi.gif from transaction SE80?

Regards

Raja

assigning points to helpful answers by choosing the appropriate radiobuttons in the answers in the SDN way of saying thanks.

0 Kudos

you can get the logical and physical id if you right click with the mouse in transaction SE80 on the filename and select "Properties".

The is no path in SE80 in the MIME-Repository showed. It's somehow organized in folders. Here the files lies in \SAP\PUBLIC\BC\Icons\s_s_keyi.gif. But I don't thinks it's the path or the url of the GIF-file.

0 Kudos

the path is right , you have to use that with the method i have suggested.

for example check out this program (for uploading / downloading MIMES)

BSP_UPDATE_MIMEREPOS

and also check out this thread

Regards

Raja