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: 

Sending an image in Email

Former Member
0 Kudos

Hi.

We have to send an external email in HTML format. The email can also have a logo/photo.

How can we achieve this?

Also, if it is possible to achieve this, can this be done in backgound also?

We are not displaying when user runs the report. Only send an email.

Thanks in adv.

1 ACCEPTED SOLUTION

Former Member

Hi Samant,

U have to set your message content type to 'HTML' instead of 'plain text', place <img> links to the images inside your message, and attach the images.

U can send the mail through program in background too.

Rgds,

Prakashsingh

15 REPLIES 15

athavanraja
Active Contributor
0 Kudos

check out this code sample, we can improve this to add images as well.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5931ff64-0a01-0010-2bb7-ff2...

Regards

Raja

Former Member

Hi Samant,

U have to set your message content type to 'HTML' instead of 'plain text', place <img> links to the images inside your message, and attach the images.

U can send the mail through program in background too.

Rgds,

Prakashsingh

0 Kudos

Thanks.

But Raja, I already saw your code before posting this.

The point is you are relying on a spool and converting it to HTML.

But my spool cannot have an image as you know.

Also, if I insert an image, I can just place a URL of that image. Is it possible ( I may sound funny ) to completly insert the picture because the user to who the email is going may not be able to access that URL.

Thanks again.

0 Kudos

Hi,

Check this.., in this have a look at Amit Program

Regards

vijay

0 Kudos

Hi Durai.

I am using your code to send email, but I am sending to SAP inbox. Everything is fine, except the image does not show up.

Here is what my HTML table looks like :

-


<html dir="ltr"><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>Report output</title>

<style>table.list { border-collapse: collapse; }</style>

</head>

<!script!>

<body bgcolor="#E8EAD8">

<blockquote>

<p align=left><font size=+2><b> </b></font></p>

<p align=left>

<font style="font-family:monospaced"><font face="courier new" size="2"><nobr><strike>----


</strike></nobr></font><br><font face="courier new" size="2"><span style="white-space:nowr

ap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0002002>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs

p;&nbsp;&nbsp;&nbsp;CONFIDENTIAL</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0003002>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb

sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</nobr></font><font face="courier new" size="2"><nobr style= color:#0273bc id=l0003035>----


</nobr></

font><font face="courier new" size="2"><nobr style= color:#0273bc id=l0003047>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Page&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</nobr></font></span></font><br><font face="courier new"

size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0004002>Program&nbsp;ID:&nbsp;ZGECVPR019&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Run&nbsp;Date:&nbsp;15.06.2006&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font

face="courier new" size="2"><nobr style= color:#0273bc id=l0005002>Printed&nbsp;By:&nbsp;VNCSSAA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PHOTO&nbsp;ALBUM&nbsp;OF&nbsp;OFFICER(S)&nbsp;&nbsp;&nbsp;Run&nbsp;Time:&nbsp;19:05&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs

p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><nobr><strike>----


</strike></nobr></font><br><font face="courier new" size="2"><s

pan style="white-space:nowrap"><font face="courier new" size="2"><nobr style= background:#E8EAD8 id=l0007002>&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr s

tyle= color:#0273bc id=l0008002>Selection&nbsp;Criteria</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= background:#E8EAD8 id=l0009002>&nbsp;</nobr></font></s

pan></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0010002>&nbsp;&nbsp;&nbsp;&nbsp;Personnel&nbsp;number&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&

nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00000033&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" siz

e="2"><nobr style= color:#0273bc id=l0011002>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00000044&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273

bc id=l0012002>&nbsp;&nbsp;&nbsp;&nbsp;Present&nbsp;Organizational&nbsp;Unit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier

new" size="2"><nobr style= color:#0273bc id=l0013002>&nbsp;&nbsp;&nbsp;&nbsp;Owner&nbsp;Organizational&nbsp;unit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</nobr></font></span></font><br><font face="courier new" size="2"><sp

an style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0014002>&nbsp;&nbsp;&nbsp;&nbsp;Number&nbsp;of&nbsp;Levels&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;:</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0015002>&nbsp;&nbsp;&nbsp;&nbsp;Present&nbsp;Position&nbsp;&nbsp;&

nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr st

yle= color:#0273bc id=l0016002>&nbsp;&nbsp;&nbsp;&nbsp;Owner&nbsp;Position&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</nobr></font></span></font><br><font face

="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0017002>&nbsp;&nbsp;&nbsp;&nbsp;Date&nbsp;of&nbsp;Appt&nbsp;to&nbsp;Service&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs

p;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" si

ze="2"><nobr style= color:#0273bc id=l0018002>&nbsp;&nbsp;&nbsp;&nbsp;Personnel&nbsp;Group&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</nobr></font></span></font><br>

<font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0019002>&nbsp;&nbsp;&nbsp;&nbsp;Appointing&nbsp;Ministry&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&

nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0020002>&nbsp;&nbsp;&nbsp;&nbsp;Substantive&nbsp;

Appointment&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc

id=l0021002>

<br class="pagebreakhere">

</nobr></font></span></font><br><font face="courier new" size="2"><nobr><strike>----


</strike></nobr></font><br><font face="courier new" size="2"><span style="whi

te-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0023002>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb

sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CONFIDENTIAL</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0024002>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n

bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</nobr></font><font face="courier new" size="2"><nobr style= color:#0273bc id=l0024035>----


-


</nobr></font><font face="courier new" size="2"><nobr style= color:#0273bc id=l0024047>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Page&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</nobr></font></span></font><br><font face="

courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0025002>Program&nbsp;ID:&nbsp;ZGECVPR019&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp

;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Run&nbsp;Date:&nbsp;15.06.2006&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:n

owrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0026002>Printed&nbsp;By:&nbsp;VNCSSAA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PHOTO&nbsp;ALBUM&nbsp;OF&nbsp;OFFICER(S)&nbsp;&nbsp;&nbsp;Run&nbsp;Time:&nbsp;19:05&nbsp;&nbsp;&nbsp;&nb

sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><nobr><strike>----


</strike></nobr></font><br><font face="courier new

" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0028002>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:no

wrap"><font face="courier new" size="2"><nobr style= background:#E8EAD8 id=l0029002>&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0

030002>

<img BORDER=0 height=170 width=132 SRC="SAPR3://SAPR3CMS/get/102/Z1/95DB4054845B6042970BF6E8D5F6335D/data">

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<img BORDER=0 height=170 width=132 SRC="SAPR3://SAPR3CMS/get/102/Z1/8DEB78F36C3D784BB9AF63EA9AD9F8C5/data">

</nobr></font></span></font><br><font face="courier new" size="2"><span style="w

hite-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0031002>00000033&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp

;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00000044&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0032002>James&nbsp;&nbsp;&nbsp;&nb

sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Lenny&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&

nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0033002>&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Customer&nbsp;Relations&nbs

p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0034002>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb

sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Officer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp

;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0035002>

<br class="pagebreakhere">

</nobr></font></s

pan></font><br><font face="courier new" size="2"><nobr><strike>----


</strike></nobr></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courie

r new" size="2"><nobr style= color:#0273bc id=l0037002>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CO

NFIDENTIAL</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0038002>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&

nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</nobr></font><font face="courier new" size="2"><nobr style= color:#0273bc id=l0038035>----


</nobr></font><font face="couri

er new" size="2"><nobr style= color:#0273bc id=l0038047>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Page&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><span style="

white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0039002>Program&nbsp;ID:&nbsp;ZGECVPR019&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs

p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Run&nbsp;Date:&nbsp;15.06.2006&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" siz

e="2"><nobr style= color:#0273bc id=l0040002>Printed&nbsp;By:&nbsp;VNCSSAA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PHOTO&nbsp;ALBUM&nbsp;OF&nbsp;OFFICER(S)&nbsp;&nbsp;&nbsp;Run&nbsp;Time:&nbsp;19:05&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n

bsp;&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><nobr><strike>----


</strike></nobr></font><br><font face="courier new" size="2"><span style="white-space

:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0042002>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp

;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size

="2"><nobr style= background:#E8EAD8 id=l0043002>&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= background:#E8EAD8 id=l0044002>&nbsp;</nobr></font></s

pan></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= color:#0273bc id=l0045002>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs

p;&nbsp;&nbsp;&nbsp;&nbsp;No&nbsp;of&nbsp;records&nbsp;selected&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= ba

ckground:#E8EAD8 id=l0046002>&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= background:#E8EAD8 id=l0047002>&nbsp;</nobr></font></span></font><br><font

face="courier new" size="2"><span style="white-space:nowrap"><font face="courier new" size="2"><nobr style= background:#E8EAD8 id=l0048002>&nbsp;</nobr></font></span></font><br><font face="courier new" size="2"><span style="white-space:nowrap"><font face

="courier new" size="2"><nobr style= color:#0273bc id=l0049002>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**&nbsp;End&nbsp;o

f&nbsp;Report&nbsp;**</nobr></font></span></font><br>

</p>

</blockquote>

</body>

</html>

===================

Notice the two IMG tags there. If I pass the same table to HTML container as in :

CALL METHOD html_control->load_data

IMPORTING

assigned_url = url

CHANGING

data_table = html

CALL METHOD cl_gui_cfw=>flush.

CALL METHOD html_control->show_data

EXPORTING

url = url.

In this case, photo comes up perfectly fine. But in email somehow the photo is not coming up.

Any clues?

Thanks again.

0 Kudos

i figured out how to include image (inline in html mail)

upload from local machine or get the binary content of the image from SAP.

then

add it as attachment to your mail

call method document->add_attachment

exporting i_attachment_type = 'jpg'

i_attachment_subject = 'scan0002'

i_att_content_hex = binary_content.

in the body of the email refer to the image attachment.

append '<html><body><img src="<b>cid:scan0002.jpg</b>"></body></html>' to text.

document = cl_document_bcs=>create_document(

i_type = 'HTM'

i_text = text

  • i_length = '12'

i_subject = 'test created by BCS_EXAMPLE_2' ).

Regards

Raja

0 Kudos

Thanks Durai. But how to get the Binary content of the image?

All I have is a URL to the image which is lying in the content server.

0 Kudos

Hi Durai.

I could not get the result. Here is the code : (I have removed declarations part to shorten it). Can you tell me where I am doing wrong?

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'C:\test.jpg'

filetype = 'BIN'

IMPORTING

filelength = l_len

TABLES

data_tab = data

EXCEPTIONS

OTHERS = 17.

objtxt = '<HTML> <BODY> <U> See this image </U>'.

APPEND objtxt.

objtxt = '</BODY> </HTML>' .

APPEND objtxt.

APPEND '<html><body><img src="cid:firstjpg.jpg"></body></html>' TO objtxt.

html[] = objtxt[].

CLEAR tmp_str .

CLEAR : html_wa .

LOOP AT html INTO html_wa .

CONCATENATE tmp_str html_wa INTO tmp_str.

ENDLOOP .

data_tab = data[].

CLEAR: conlength,conlengths .

conlength = STRLEN( tmp_str ) .

conlengths = conlength .

subject = 'Email JPG'.

TRY.

CLEAR send_request .

send_request = cl_bcs=>create_persistent( ).

CLEAR document .

document = cl_document_bcs=>create_document(

i_type = 'HTM'

i_text = html

i_length = conlengths

i_subject = subject ).

  • add document to send request

CALL METHOD document->add_attachment

EXPORTING

i_attachment_type = 'jpg'

i_attachment_subject = 'firstjpg'

i_att_content_hex = data_tab.

CALL METHOD send_request->set_document( document ).

CLEAR sender_id .

l_username = p_user.

TRANSLATE l_username TO UPPER CASE.

recipient = cl_sapuser_bcs=>create( l_username ).

CALL METHOD send_request->add_recipient

EXPORTING

i_recipient = recipient

i_express = 'X'.

CALL METHOD send_request->set_status_attributes

EXPORTING

i_requested_status = 'E'

i_status_mail = 'E'.

CALL METHOD send_request->set_send_immediately( 'X' ).

  • ---------- send document ---------------------------------------

CALL METHOD send_request->send(

EXPORTING

i_with_error_screen = 'X'

RECEIVING

result = sent_to_all ).

IF sent_to_all = 'X'.

APPEND 'Mail sent successfully ' TO return .

ENDIF.

COMMIT WORK.

CATCH cx_bcs INTO bcs_exception.

bcs_message = bcs_exception->get_text( ).

APPEND bcs_message TO return .

EXIT.

ENDTRY.

0 Kudos

hre is a working version. just change the email id and the path of the image.

as for getting the image from content server - there should be native ABAP FM to get the content or if the content server is HTTP enabled, use the url along with cl_http_client or http_get FM to get the content.

REPORT bcs_example_5.

* This example shows how to send
*   - a simple text provided in an internal table of text lines
*   - and an attached MS word document provided in internal table
*   - to some internet email address.
*
* All activities done via facade CL_BCS!

DATA: send_request       TYPE REF TO cl_bcs.
DATA: text               TYPE bcsy_text.
data: binary_content     type solix_tab.
DATA: document           TYPE REF TO cl_document_bcs.
DATA: sender             TYPE REF TO cl_sapuser_bcs.
DATA: recipient          TYPE REF TO if_recipient_bcs.
DATA: bcs_exception      type ref to cx_bcs.
data: sent_to_all        type os_boolean.
data: filelength type i .

START-OF-SELECTION.

CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    filename                      = 'd:Documents and SettingsddddDesktoptest.jpg'
   FILETYPE                      = 'BIN'
*   HAS_FIELD_SEPARATOR           = 'X'
*   HEADER_LENGTH                 = 0
*   READ_BY_LINE                  = 'X'
*   DAT_MODE                      = ' '
*   CODEPAGE                      = ' '
*   IGNORE_CERR                   = ABAP_TRUE
*   REPLACEMENT                   = '#'
*   CHECK_BOM                     = ' '
*   VIRUS_SCAN_PROFILE            = VIRUS_SCAN_PROFILE
 IMPORTING
   FILELENGTH                    = FILELENGTH
*   HEADER                        = HEADER
  TABLES
    data_tab                      = binary_content
 EXCEPTIONS
   FILE_OPEN_ERROR               = 1
   FILE_READ_ERROR               = 2
   NO_BATCH                      = 3
   GUI_REFUSE_FILETRANSFER       = 4
   INVALID_TYPE                  = 5
   NO_AUTHORITY                  = 6
   UNKNOWN_ERROR                 = 7
   BAD_DATA_FORMAT               = 8
   HEADER_NOT_ALLOWED            = 9
   SEPARATOR_NOT_ALLOWED         = 10
   HEADER_TOO_LONG               = 11
   UNKNOWN_DP_ERROR              = 12
   ACCESS_DENIED                 = 13
   DP_OUT_OF_MEMORY              = 14
   DISK_FULL                     = 15
   DP_TIMEOUT                    = 16
   OTHERS                        = 17
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.



    PERFORM main.


*---------------------------------------------------------------------*
*       FORM main                                                     *
*---------------------------------------------------------------------*
FORM main.

  try.
*     -------- create persistent send request ------------------------
      send_request = cl_bcs=>create_persistent( ).

*     -------- create and set document with attachment ---------------
*     create document from internal table with text
      APPEND '<html><body><img src="cid:scan0002.jpg"></body></html>' TO text.
      document = cl_document_bcs=>create_document(
                      i_type    = 'HTM'
                      i_text    = text
*                      i_length  = '12'
                      i_subject = 'test created by BCS_EXAMPLE_2' ).

*     add attachment to document
*     BCS expects document content here e.g. from document upload
*     binary_content = ...
      CALL METHOD document->add_attachment
        EXPORTING  i_attachment_type = 'jpg'
                   i_attachment_subject = 'scan0002'
                   i_att_content_hex    = binary_content.

*     add document to send request
      CALL METHOD send_request->set_document( document ).

*     --------- set sender -------------------------------------------
*     note: this is necessary only if you want to set the sender
*           different from actual user (SY-UNAME). Otherwise sender is
*           set automatically with actual user.

      sender = cl_sapuser_bcs=>create( sy-uname ).
      CALL METHOD send_request->set_sender
        EXPORTING i_sender = sender.

*     --------- add recipient (e-mail address) -----------------------
*     create recipient - please replace e-mail address !!!
      recipient = cl_cam_address_bcs=>create_internet_address(
                                        'raja@xxx.com' ).

*     add recipient with its respective attributes to send request
      CALL METHOD send_request->add_recipient
        EXPORTING
          i_recipient  = recipient
          i_express    = 'X'.
 CALL METHOD send_request->set_send_immediately( 'X' ).

*     ---------- send document ---------------------------------------
      CALL METHOD send_request->send(
        exporting
          i_with_error_screen = 'X'
        receiving
          result              = sent_to_all ).
      if sent_to_all = 'X'.
        write text-003.
      endif.

      COMMIT WORK.


* -----------------------------------------------------------
* *                     exception handling
* -----------------------------------------------------------
* * replace this very rudimentary exception handling
* * with your own one !!!
* -----------------------------------------------------------
  catch cx_bcs into bcs_exception.
    write: 'Fehler aufgetreten.'(001).
    write: 'Fehlertyp:'(002), bcs_exception->error_type.
    exit.

  endtry.

ENDFORM.

0 Kudos

Can the same be used for pdf too. Need external pdf as attachment.

Former Member
0 Kudos

HI

GOOD

GO THROUGH THIS WEBLOG LINK , I HOPE THIS WILL HELP YOU TO SOLVE YOUR PROBLEM.

/people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp

THANKS

MRUTYUN

0 Kudos

so in your abap program you will construct the html page? right

you have to store the images in MIME repository of the system and provide a link to them in the html page.

when you send it to users and when they try to open it it will ask for authentication (to sap system) so that it can read the image. if you want to avoid this authentication, then you have to hadrd code a user id pwd in the MIME repository folder in SICF.

below i am pasting a code where you can pass any html content and the same can be emailed. (for top include code refer to the code sample i had given, its the same)

FUNCTION y_email_simple_html.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(SENDER_ID) TYPE  AD_SMTPADR
*"     REFERENCE(SUBJECT) TYPE  SO_OBJ_DES
*"     REFERENCE(MESSAGE) TYPE  STRING
*"  TABLES
*"      RECEPIENTS TYPE  BCSY_SMTPA
*"      RETURN TYPE  TABLE_OF_STRINGS OPTIONAL
*"----------------------------------------------------------------------
  DATA: tmp_str TYPE string .

  IF NOT recepients[] IS INITIAL .
    CLEAR result_content.
    result_content = message .

    CLEAR : server, port .
    CALL FUNCTION 'TH_GET_VIRT_HOST_DATA'
       EXPORTING
         protocol             = 1
         virt_idx             = 0
*   LOCAL                = 1
      IMPORTING
        hostname             = server
        port                 = port
      EXCEPTIONS
        not_found            = 1
        internal_error       = 2
        OTHERS               = 3 .
    CLEAR tmp_str .
    CONCATENATE 'http://' server ':' port '/sap/public/' INTO tmp_str .

    REPLACE ALL OCCURRENCES OF '/sap/public/' IN result_content WITH tmp_str .
    CLEAR tmp_str .
    CLEAR: conlength,conlengths .

    conlength = STRLEN( result_content ) .
    conlengths = conlength .

    REFRESH text .
    CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
      EXPORTING
        text      = result_content
      TABLES
        ftext_tab = text.



    TRY.
        CLEAR send_request .

        send_request = cl_bcs=>create_persistent( ).

        CLEAR document .
        document = cl_document_bcs=>create_document(
                        i_type    = 'HTM'
                        i_text    = text
                        i_length  = conlengths
                        i_subject = subject ).

*     add document to send request
        CALL METHOD send_request->set_document( document ).

        CLEAR sender .
        sender = cl_cam_address_bcs=>create_internet_address( sender_id ).
        CALL METHOD send_request->set_sender
          EXPORTING
            i_sender = sender.

        CLEAR wa_rec .

        LOOP AT recepients INTO wa_rec  .
          CLEAR recipient .

          recipient = cl_cam_address_bcs=>create_internet_address(
                                            wa_rec ).

*     add recipient with its respective attributes to send request
          CALL METHOD send_request->add_recipient
            EXPORTING
              i_recipient = recipient
              i_express   = 'X'.
        ENDLOOP .
        CALL METHOD send_request->set_status_attributes
          EXPORTING
            i_requested_status = 'E'
            i_status_mail      = 'E'.

        CALL METHOD send_request->set_send_immediately( 'X' ).
*     ---------- send document ---------------------------------------
        CALL METHOD send_request->send(
          EXPORTING
            i_with_error_screen = 'X'
          RECEIVING
            result              = sent_to_all ).
        IF sent_to_all = 'X'.
          APPEND 'Mail sent successfully ' TO return .
        ENDIF.

        COMMIT WORK.

* -----------------------------------------------------------
* *                     exception handling
* -----------------------------------------------------------
* * replace this very rudimentary exception handling
* * with your own one !!!
* -----------------------------------------------------------
      CATCH cx_bcs INTO bcs_exception.
        bcs_message = bcs_exception->get_text( ).
        APPEND bcs_message TO return .
        EXIT.

    ENDTRY.
  ELSE .

    APPEND 'Specify email address for sending' TO return .
  ENDIF .



ENDFUNCTION.

Regards

Raja

0 Kudos

Sry,

i have written the program as u did in the third example i.e using bcs_example_5. i am getting the image as attachment and it is displaying in the body only when i select or click on the attachment. can you please suggest me how the image displays by defalut in the email body.I am sending the mail to my outlook mail id.

****urgent*****

Regards,

Madhu

Message was edited by:

madhu reddy

Former Member
0 Kudos

Thanks Durai.

Still the same thing. No image comes up in the body. Only attachment. I guess I am sending to SAP inbox and it doesn't work there.

Could not try sending to external mail client as it is not configured in our system till now. Can you test sending to SAP inbox in your system please? thanks again.

0 Kudos

it doesnt work with SAP inbox. it works with outlook