05-14-2009 9:44 PM
Hello Gurus,
I have an ABAP program that creates an email and sends it to a list of Users, this works with no
problems, I'm using the CL_BCS class to do this.
My problems is that they want to include a logo in the body of the email (no attachment)
and I have searched SDN but haven't found my answers.
I need your help.
Thank you in advance.
05-14-2009 9:49 PM
05-14-2009 9:49 PM
05-14-2009 11:04 PM
Hi,
First you need to place your logo using OAER tcode. Once it is there (on application serv) you need to create an url from it.
Then simply add this url to html tab << img src="url" >> . When creating bcs document, pass HTML type as message type and html tab as email body.
"1. ------------------------------------------ creating url
DATA: pick_data TYPE TABLE OF w3mime,
it_query TYPE TABLE OF w3query,
wa_query TYPE w3query,
it_html TYPE TABLE OF w3html,
return_code TYPE w3param-ret_code,
content_type TYPE w3param-cont_type,
content_length TYPE w3param-cont_len,
url(255) TYPE c,
pic_size TYPE i.
REFRESH it_query.
wa_query-name = '_OBJECT_ID'.
wa_query-value = 'ENJOYSAP_LOGO'. "node name in OAER where your picture was placed
APPEND wa_query TO it_query.
CALL FUNCTION 'WWW_GET_MIME_OBJECT'
TABLES
query_string = it_query
html = it_html
mime = pick_data
CHANGING
return_code = return_code
content_type = content_type
content_length = content_length
EXCEPTIONS
invalid_table = 1
parameter_not_found = 2
OTHERS = 3.
IF sy-subrc = 0.
pic_size = content_length.
ENDIF.
CLEAR url.
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'image'
subtype = 'X-UNKNOWN'
size = pic_size
lifetime = 'T'
TABLES
data = pick_data
CHANGING
url = url
EXCEPTIONS
OTHERS = 1.
"2. ------------------------------ adding html tags
data: lt_message TYPE bcsy_text with header line.
concatenate: '<<img src="' url '">>' to lt_message. "use "<" ">" only once (it can't be displayed here correctly)
append lt_message.
"3. ------------------------------ setting message type in email body
data lr_email TYPE REF TO cl_bcs,
lr_email_body = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = lt_message
i_subject = l_subject ).
lr_email->set_document( lr_email_body ).
Regards
Marcin
07-27-2011 7:13 AM
Hi
I have done everything you said to take url and use bc class to send picture in body of email by using
html tag <img>
I am not able to see the picture.
I am getting message "Right Click Here to Download Picture. To help protect your privacy. Outlook prevented autometic download of picture from the internet."
Waiting for your reply.
Thanks & Regards,
Ravi Grover
01-23-2012 10:16 AM
Hi Experts,
Can anyone share your experience on this issue? I have also uploaded the logo in MIME repository and I 'DP_CREATE_URL' function module to get the URL. However when code the html statement with this URL, and use the function module SO_NEW_DOCUMENT_ATT_SEND_API1, instead of the logo there appears a box with an 'x' in it just like some one mentioned above. The URL obtained from the function is SAPR3://76401C4FC5E8E319E1000000C0A8648B which does not look like a valid url for the html coding. Please help me with this as I have been trying my level best for the last 4 days for this with no avail.
Thanks
Ajith c
01-25-2012 9:47 AM
Has anybody resolve this? i am facing the same problem as Ajith's.
Kindly let me know how to solve that. i m getting an URL like above and picture is not getting displayed.
i followed all the above steps.
08-02-2009 2:42 PM
Hello Ruben,
I'm quite new in ABAP and I have to create a programm which sends e-mail to specified SAP users.
I've just read that you have such a programm and I would like to ask you to send it to me to take a look at it to have a source of inspiration.
Thank you in advance.
P. S.: I couldn't include my e-mail address, but if you need it, please notify it.
08-03-2009 1:21 PM
Hello Neomi,
I noticed that your inquiry was answered.
Regards,
Ruben.
08-03-2009 5:09 PM
Hello Neomi,
Because of Company policy I cannot send you the complete program, but I will let you know what I did.
Our customer wanted a customer table set up with customer number and Email address, I did this with a separate ABAP
program to allow someone to enter this information, you could use SM30 to enter data if security is not an issue were you work.
Then, I created the following to send an email to those clients whenever they have invoices availble for lookup under our customer Portal.
The code to send the email is as follows...
TYPES: BEGIN OF xadr6,
smtp_addr TYPE adr6-smtp_addr,
END OF xadr6.
DATA : l_o_send_request TYPE REF TO cl_bcs, " email request object
l_o_document TYPE REF TO cl_document_bcs, " documents object
l_o_sender TYPE REF TO cl_cam_address_bcs, " sender object
l_o_recipient TYPE REF TO cl_cam_address_bcs, " recipient object
bcs_exception TYPE REF TO cx_bcs, " exceptions
sent_to_all TYPE os_boolean,
l_it_contents TYPE bcsy_text,
l_wa_contents TYPE LINE OF bcsy_text,
v_address TYPE adr6-smtp_addr.
*-Create l objects
l_o_send_request = cl_bcs=>create_persistent( ).
*-Sender(v_address = You can have static EMAIL Address for sender or different EMAIL addresses )
l_o_sender = cl_cam_address_bcs=>create_internet_address( v_address ).
l_o_send_request->set_sender( i_sender = l_o_sender ).
*-Recipient TO
l_o_recipient = cl_cam_address_bcs=>create_internet_address( ls_adr6-smtp_addr ).
l_o_send_request->add_recipient( i_recipient = l_o_recipient
i_copy = '' ). " CC indicator
*-Contents (Body)
*Here we're sending the body in HTML
REFRESH: l_it_contents.
CLEAR: l_it_contents.
CLEAR l_wa_contents.
l_wa_contents-line = '<html>'.
APPEND l_wa_contents TO l_it_contents.
CLEAR l_wa_contents.
l_wa_contents-line = '<body>'.
APPEND l_wa_contents TO l_it_contents.
CLEAR l_wa_contents.
....(In here you can insert the message you want to send in your email, follow the HTML format)
For example
l_wa_contents-line = 'Dear Portal User,'.
APPEND l_wa_contents TO l_it_contents.
CLEAR l_wa_contents.
..... (etc)
l_wa_contents-line = '</body>'.
APPEND l_wa_contents TO l_it_contents.
CLEAR l_wa_contents.
l_wa_contents-line = '</html>'.
APPEND l_wa_contents TO l_it_contents.
*-Create documents
l_o_document = cl_document_bcs=>create_document(
i_type = 'HTM' " RAW document format
i_text = l_it_contents
i_subject = 'This is my Subject').
l_o_send_request->set_document( l_o_document ).
*-Set sending options (no return or read receipt)
CALL METHOD l_o_send_request->set_status_attributes
EXPORTING
i_requested_status = 'N' "Choices are: A - Message for every status
i_status_mail = 'N'. " E - Message only in the event of error - Default
*-Send email " N - No status confirmation at all
l_o_send_request->set_send_immediately( 'X' ).
sent_to_all = l_o_send_request->send(
i_with_error_screen = 'X' ).
Hope this helps.
Regards,
Ruben.
Edited by: Ruben Diaz on Aug 3, 2009 6:09 PM
Edited by: Ruben Diaz on Aug 3, 2009 6:11 PM
Edited by: Ruben Diaz on Aug 3, 2009 6:14 PM
08-16-2009 8:32 PM
Hello Ruben,
Thank you for your answer.
I looked into the matter again using your ideas, but I still have a question:
I don't exactly know where to put the code that sends an e-mail to make the e-mail sending process automatical whenever users log on with the new passwords.
I've read about changing a user exit, but do you know if there is a simpler way to solve this problem or is this the right solution?
Thank you,
Noemi
08-17-2009 1:49 PM
Hi Neomi,
If you're looking to send the email right after they change the password then I think using the userexit related to
login mechanism is acceptable. I am not sure as to which one it is but I am sure you can find it suing SDN.
Regards,
Ruben.
08-11-2010 1:54 PM
Hi Ruben,
I am also doing a program that adds a logo on the footer section of the email.
Can you also show me the code on adding the logo to the email message?
Your help is much appreciated.
Thank you.
Onyx.
08-11-2010 2:50 PM
Hi Ruben,
I am also doing a program that sends an email which has a logo on it.
I would just like to ask about the code on how the logo be included in the body of the email.
Thank you.
Your help is highly appreciated.
Onyx
08-11-2010 2:52 PM
Hi Ruben,
I am also doing a program that sends an email with a logo on it.
I would just like to ask then about the code on how to include the logo in the body of the message.
Thank you.
Your help is highly appreciated.
Onyx