Send HTML mail with image
Hi experts and gurus,
how can I send an HTML email which is displaying an image in the HTML context (table)?
I'm using the 'SO_NEW_DOCUMENT_SEND_API1' like below:
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = ls_doc_data
document_type = 'HTM'
put_in_outbox = 'X'
commit_work = 'X'
TABLES
object_content = gt_mail_body
receivers = gt_receiver .
I think that might switch to function module 'SO_NEW_DOCUMENT_ATT_SEND_API1', but I have no clue how to set up the PACKING_LIST properly and to incorporate the image into the HTML code afterwards.
Can anybody help me?
Regards, Steffen
Hi,
I am also trying to send the image in the mail body but the image is not being displayed in the mail.
I am using cl_bcs class to send the image as the attachment in the mail and the body content but the
image is not being displayed instead all I can see a box with red cross however, the attached gets open.
But it is not able to find the image source I guess.
I am using Lotus notes to check the mail.
Please help me ......
I am uploading the image file from desktop into my code then I am attaching it in the mail.
Please let me know the solution
The code is as follows :
REPORT ztest_mail_544.
DATA: l_send_request TYPE REF TO cl_bcs,
l_document TYPE REF TO cl_document_bcs,
l_sender TYPE REF TO cl_sapuser_bcs,
l_sub TYPE char50,
l_recipient TYPE REF TO if_recipient_bcs,
tl_contents TYPE STANDARD TABLE OF soli,
tl_reciev TYPE STANDARD TABLE OF somlreci1,
lp_encrypt TYPE bcsd_encr,
wa_contents TYPE solisti1,
l_doc_len TYPE so_obj_len,
l_cnt TYPE sy-tabix,
l_rcv_email TYPE adr6-smtp_addr,
l_result TYPE sy-binpt,
l_bcs_exception TYPE REF TO cx_bcs,
l_subj TYPE string,
l_doc TYPE REF TO cl_document_bcs,
e_result TYPE sr_state,
ls_receivers TYPE somlreci1,
ll_text TYPE uname.
DATA filename TYPE string .
DATA : it_tab TYPE solix_tab.
filename = 'C:\Documents and Settings\Desktop\otter.jpg'.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
filetype = 'BIN'
TABLES
data_tab = it_tab
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
wa_contents-line = 'Mail containing pics <br/>'.
APPEND wa_contents TO tl_contents.
CLEAR wa_contents.
wa_contents-line = '<p><img src="otter.jpg" width="304" height="228"></img > </p><br/>'.
APPEND wa_contents TO tl_contents.
TRY.
*-- Create persistent send request
l_send_request = cl_bcs=>create_persistent( ).
tl_contents[] = it_mail_body[].
*-- Get the length of the Document
DESCRIBE TABLE tl_contents LINES l_cnt.
READ TABLE tl_contents INTO wa_contents INDEX l_cnt.
l_doc_len = ( l_cnt - 1 ) * 255 + STRLEN( wa_contents ).
*-- Subject of the mail
CLEAR l_sub.
l_sub = 'test mail for image'.
l_document = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = tl_contents
i_length = l_doc_len
i_subject = l_sub
i_language = sy-langu
i_importance = '9' ).
*-- Add document to send request
CALL METHOD l_send_request->set_document( l_document ).
*-- Don't send delivery info for successful mails
CALL METHOD l_send_request->set_status_attributes
EXPORTING
i_requested_status = 'E'
i_status_mail = 'A'.
*-- Set sender
l_sender = cl_sapuser_bcs=>create( 'HR_SUPPORT' ).
CALL METHOD l_send_request->set_sender
EXPORTING
i_sender = l_sender.
DATA : i_attachment_type TYPE soodk-objtp,
i_attachment_subject TYPE sood-objdes .
DATA : t_attachment TYPE STANDARD TABLE OF solix.
TRY.
l_att_type = i_attachment_type.
l_subject = i_attachment_subject.
i_attachment_type = 'jpg'.
t_attachment[] = it_tab[].
l_doc = l_document .
i_attachment_type = space.
i_attachment_subject = 'otter.jpg'.
CALL METHOD l_doc->add_attachment
EXPORTING
i_attachment_type = i_attachment_type
i_attachment_subject = i_attachment_subject
i_att_content_hex = t_attachment.
CATCH cx_document_bcs.
ENDTRY.
l_recipient = cl_cam_address_bcs=>create_internet_address('xyz @abc.com' ).
CALL METHOD l_send_request->add_recipient
EXPORTING
i_recipient = l_recipient
i_express = 'X'
i_copy = ''
i_blind_copy = ''.
IF sy-subrc = 0.
ENDIF.
CALL METHOD l_send_request->set_send_immediately( 'X' ).
*-- Send Email
CALL METHOD l_send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = l_result ).
COMMIT WORK.
CATCH cx_bcs INTO l_bcs_exception.
write : 'mail not sent '.
Similar Messages
-
How to send HTML mail with images multipart/related message
Hi,
Could any body tell me how to send HTML mail with images in "multipart/related" message,if any body can give the code ,it would be helpful.
ThanksHi,
Could any body tell me how to send HTML mail with
ith images in "multipart/related" message,if any body
can give the code ,it would be helpful.
ThanksHi!
Refer to
http://developer.java.sun.com/developer/onlineTraining/JavaMail/index.html
I've found it very helpful.
Look at the last part for a code showing how to send HTML mail!
Regards -
Hi there,
I'm trying to send html mail with an image. I'm able to see the image but in another section, at the very bottom of my message. Is it possible to display the image in the main part of my message ?
Here my code :
MimeMultipart multi = new MimeMultipart();
BodyPart messageBodyPart = new MimeBodyPart();
String htmlText = <H1>Test</H1><img src=\"cid:image\">";
messageBodyPart.setContent(htmlText, "text/html");
multi.addBodyPart(messageBodyPart);
MimeBodyPart imagePart = new MimeBodyPart();
DataSource fds = new FileDataSource("C:\\Resources\\Templates\\logo.jpg");
imagePart.setFileName( "geologo.jpg" );
imagePart.setDataHandler(new DataHandler(fds));
imagePart.setHeader("Content-ID","<image>");
multi.addBodyPart(imagePart);
msg.setContent(multi);
Transport.send(msg);How many different e-mail clients have you tested that with?
-
Procedure or Function that send E-mail with image background and file attached
hi
I4d like know if someone there is a procedure or function that send E-mail with image background and file attached, for me.
thanks
Josi VieiraIf you go to this part of OTN you will find the official Oracle UTL_SMTP demo, which includes attachments:
http://technet.oracle.com/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html
Getting a background is slightly trickier. The UTL_SMTP package is for primarily sending text e-mails, whereas images require HTML e-mail. I suggest you look at the structure of a sample HTML e-mail and see if you can write the necessary HTML strings in the DATA parameter. Otherwise you'll need to investigate handcrafting a program based on the UTL_TCP package.
[rant]
If this seems like a lot of trouble I agree and urge you not to bother. HTML e-mail is one of the curses of the modern age, not least because it is frequently used by purveyors of viruses. I have a filter on my Outlook client that strips out all the HTML in any e-mail I receive, which means I get lots of e-mails rendered unreadable by the inclusion of <HTML> tags. But who cares, they're mostly spam anyway. In fact, the use of HTML in an e-mail is almost always an indicator of the irrelevance of its content.
[rant]
Vibes, APC -
Hi
Does anybody knows how to send a HTML mail with flash to a
person?
grtz
TomHi!
You need to use a serverside script like php or asp. I have a
html string in
the swf which I send as LoadVars.send() to the server.
Of cource the server has to be configured correctly to
support the mail
function.
//Micke
"MatMaar" <[email protected]> skrev i
meddelandet
news:e3atb2$c2r$[email protected]..
> Hi
>
> Does anybody knows how to send a HTML mail with flash to
a person?
>
> grtz
> Tom -
Send html email with image embedded
Hi Guys,
I want send an email using class CL_BCS.
Can someone please help me to tell me how can we send the email with image embedded in the body?
The image is stored in the mime repository and was uploaded through se78.
I have searched online but am not able to send it.
It will be great if someone has working code for this.
Regards,
Dhruv KashyapHi go to T-code : SMW0 -- To upload the images , after that you can find that entries in wwwparams table .
Refer this .
**************** - Display images (like company logo) on the selection-screen
In order to send it as email you have to add attachment type as BMP from you BCS class.
Just try you can . -
Send html mail with apple mail
I used to send a html newsletter with apple mail. I opened the html file in safari pressed cmd + i and a html mail was created. On Yosemite there seems to be a bug with this feature. After pressing cmd + i it creates a mail and html website is selected in this mail, but the mail body is empty. Now I have no ideo how to send the newsletter. Apple mail was the only way to achive a correctly displayed newsletter on most common mail clients.
Does anyone have the same problem or a solution?Seems to be a bug in Safari under Yosemite. Occurs only with HTML pages which are stored locally on the Mac and then opened with Safari.
Two options for a work around:
(1)
When Apple Mail shows a blank page, choose PDF instead of WEB PAGE in the mail header.
Thereafter, the contents will appear as a PDF attachment.
(2)
Publish the HTML page. Surf with Safari to the published page. Use the command "File : Send : Email this page".
Now it should work. -
Send html mail with navigateToURL(new URLRequest('mailto:
hi!
do you think its possible, to send html text to the email client of the mobile device?
i tried different ways, but without success.
Way 1
navigateToURL(new URLRequest('mailto:[email protected]'+'?subject=Subject'+'&body= <html><body>Hello world<br><img src="http://www.republicofcode.com/wp-content/uploads/2012/04/Pins2_300_250.png"></body></html>'));
Way 2
var hdr:URLRequestHeader = new URLRequestHeader("Content-type", "text/html");
var request:URLRequest = new URLRequest('mailto:[email protected]?subject=Subject&body=<html><body>Hello world<br><img src="http://www.republicofcode.com/wp-content/uploads/2012/04/Pins2_300_250.png"></body></html>');
request.requestHeaders.push(hdr);
navigateToURL(request);
Maybe i need another content type than text/html?
In the reference i've read, that the default one is: application/x-www-form-urlencoded
http://help.adobe.com/de_DE/FlashPlatform/reference/actionscript/3/flash/net/URLRequest.ht ml#contentType
Any ideas?you could try:
function submitPoll(e:MouseEvent):void {
//sending the email stuff
var request:URLRequest = new URLRequest("mailto:[email protected]"+"?subject=Subject"+"&body= Hello world ");
navigateToURL(request, "_blank");
request.method = URLRequestMethod.POST; -
Send html page (with images) using sockets
I am trying to implement http and am coding this using sockets. So it is a simple client-server set up where the browser queries my server for a webpage and it should be shown. The html itself is fine, but I can't get any of the images to show up! All of my messages give me a status "200 OK" for the images, so I cant understand what my problem is!
Also, is the status and header lines supposed to be shown in the browser? I didnt think so but it keeps showing up when I query a webpage.
Please help!
import java.io.* ;
import java.net.* ;
import java.util.* ;
public final class WebServer
public static void main(String argv[]) throws Exception
// Set the port number.
int port = 8888;
// Establish the listen socket.
ServerSocket ssocket = new ServerSocket(port);
// Establish client socket
Socket csocket = null;
// Process HTTP service requests in an infinite loop.
while (true)
// Listen for a TCP connection request.
// (note: this blocks until connection is made)
csocket = ssocket.accept();
// Construct an object to process the HTTP request message.
HttpRequest request = new HttpRequest(csocket);
// Create a new thread to process the request.
Thread thread = new Thread(request);
// Start the thread.
thread.start();
final class HttpRequest implements Runnable
final static String CRLF = "\r\n";
Socket socket;
// Constructor
public HttpRequest(Socket socket) throws Exception
this.socket = socket;
// Implement the run() method of the Runnable interface.
public void run()
try
processRequest();
catch (Exception e)
System.out.println(e);
private static void sendBytes(FileInputStream fis, OutputStream os)
throws Exception
// Construct a 1K buffer to hold bytes on their way to the socket.
byte[] buffer = new byte[1024];
int bytes = 0;
// Copy requested file into the socket's output stream.
while((bytes = fis.read(buffer)) != -1 ) {
os.write(buffer, 0, bytes);
os.flush();
private static String contentType(String fileName)
fileName = fileName.toLowerCase();
if(fileName.endsWith(".htm") || fileName.endsWith(".html")) {
return "text/html";
if(fileName.endsWith(".jpg") || fileName.endsWith(".jpeg") ) {
return "image/jpeg";
if(fileName.endsWith(".gif")) {
return "image/gif";
return "application/octet-stream";
private void processRequest() throws Exception
// Get a reference to the socket's input and output streams.
InputStream is = socket.getInputStream();
DataOutputStream os = new DataOutputStream(socket.getOutputStream());
// Set up input stream filters.
InputStreamReader ir = new InputStreamReader(is);
BufferedReader br = new BufferedReader(ir);
// Get the request line of the HTTP request message.
String requestLine = br.readLine();
// Display the request line.
System.out.println();
System.out.println(requestLine);
// Get and display the header lines.
String headerLine = null;
while ((headerLine = br.readLine()).length() != 0)
System.out.println(headerLine);
// Extract the filename from the request line.
StringTokenizer tokens = new StringTokenizer(requestLine);
tokens.nextToken(); // skip over the method, which should be "GET"
String fileName = tokens.nextToken();
// Prepend a "." so that file request is within the current directory.
fileName = "C:\\CSM\\Networking\\Project1" + fileName;
// Open the requested file.
FileInputStream fis = null;
boolean fileExists = true;
try {
fis = new FileInputStream(fileName);
} catch (FileNotFoundException e) {
fileExists = false;
// Construct the response message.
String statusLine = null;
String contentTypeLine = null;
String entityBody = null;
if (fileExists) {
statusLine = "200 OK" + CRLF;
contentTypeLine = "Content-type: " +
contentType( fileName ) + CRLF
+ "Content-length: " + fis.available() + CRLF;
else {
statusLine = "404 Not Found" + CRLF;
contentTypeLine = "Content-type: text/html" + CRLF;
entityBody = "<HTML>" +
"<HEAD><TITLE>Not Found</TITLE></HEAD>" +
"<BODY>Not Found</BODY></HTML>";
// Send the status line.
os.writeBytes(statusLine);
System.out.println(statusLine);
// Send the content type line.
os.writeBytes(contentTypeLine);
System.out.println(contentTypeLine);
// Send a blank line to indicate the end of the header lines.
os.writeBytes(CRLF);
// Send the entity body.
if (fileExists)
sendBytes(fis, os);
fis.close();
// file does not exist
else
os.writeBytes(entityBody);
// Close streams and socket.
os.flush();
os.close();
br.close();
socket.close();
}ok. i figured it out. STUPID mistake. i forgot to include "HTTP/1.1" in my status line!!!
-
Sending HTML mail with swnconfig/swn-selsen
Hi,
I have made configuration with SWNCONFIG to send notification by Email in HTML format.
I've a problem, the task description is well in HTML but in a file attachement, what
I want is the body of the email in HTML with the task description and no file attachement.
Have you some idee ?
Thanks for you help.
Pierrick LEONARDNobody can help me ?
-
Sample Java Code to send an HTML mail with embeded image
Hello,
Please can I get a sample Java code on sending an HTML mail with embeded image.
The HTML message and relevant input parameters withhbe supplied from a PL/SQL that will call the class , the class will embed the image and send the mail to the recepient.tev wrote:
Please can I get a sample Java codeNo. This is a forum, not a code mill.
Recommended reading: How to ask questions the smart way
db -
Using Safari to send HTML Mail message but Mail keeps dropping images?
I'd like to use Safari to send html Mail messages, but when I click on File>Mail Contents... Mail opens a new window but my graphics are gone. (I'm creating the html pages using MS Word for the Mac.) I get a flash of the graphics for a second, and then they are replaced by a little blue lego. Any ideas? I've tried all kinds of mail preferences but nothing seems to help.
Figured it out (at least one way): had to load the image to a server and then add the image as a link only (uncheck "save picture with document" box).
-
How to send a mail with HTML body from Oracle
Hi Team,
Can somebody guide me how to send a mail with HTML body from oracle.
Here is the piece of code i am trying to send a mail.
procedure SEND_MAIL is
cursor c_1 is select * from table_name;
l_mail_id varchar2(40);
-- ls_mailhost VARCHAR2(64) := Mailhost;
ls_from VARCHAR2(64) := ‘[email protected]’
ls_subject VARCHAR2(200);
ls_to VARCHAR2(64);
l_mail_conn UTL_SMTP.connection;
ls_left_menu_name VARCHAR2(64);
ll_emp_num number(8);
begin
for i in c_1 loop
begin
l_mail_conn := UTL_SMTP.OPEN_CONNECTION('IP');
UTL_SMTP.HELO(l_mail_conn, 'IP');
UTL_SMTP.MAIL(l_mail_conn, LS_FROM);
UTL_SMTP.RCPT(L_mail_conn, LS_TO);
UTL_SMTP.DATA(l_mail_conn,'From: ' ||ls_from || utl_tcp.crlf ||
'To: ' ||ls_to || utl_tcp.crlf ||
'Subject: ' ||ls_subject|| utl_tcp.crlf);
UTL_SMTP.QUIT(l_mail_conn);
exception
when no_data_found then
null;
when others then
RAISE_APPLICATION_ERROR(-20000, 'Failed to send mail due to the following error: ' || sqlerrm);
end;
end loop;
end;
ThnxHi Nicolas!
Have you tried to set "Output Format" for "RAW Text" to HTM in SCOT.
If HTM is missing in your dropdown-list, you could check out table SXCONVERT2. Copy the line with category T/format TXT, and change the format from TXT to HTM. The existing function
SX_OBJECT_CONVERT__T.TXT does not need to be changed. Now you should be able to choose HTM in SCOT. You will probably need som HTML-tags in your text to make it look good.
Hope this helps!
Regards
Geir -
Isn't it possible to send Html Mail through navigateToUrl() with contentType "text/html" for Android ? please suggest any workaround
ThanksAHHHH
What you can do to make HTML for Apple Mail is to make it in an HTML editor, open it with Safari use CMD+i - a new mail message will appear in a moment with the web page in the email body.
You can't do any major editing in Mail, you'll have to go back to the HTML file. But it works.
You can also use Copy (from a web page) and then (Edit) Paste as HTML (that what Paste as HTML is for, not for creating HTML email). You can also user Paste as HTML to copy/paste a HTML email you receive or part of a HTML email. -
I've created what the php manual says should work to send
html mail to our customer automatically from the website after a
purchase, along with headers to send a bcc to us.
But the finished product coming out of DW is a message body
with all the code tags and headers in the body of the email, not a
nice html email.
I originally created this in GL, and have brought it over to
DW.
Is there maybe a better way to do this?
Here's my code:That should work fine, I believe.
But there are commercial products that may be what you would
want to
consider. WebAssist has one called UniversalEmail, that I
like very much -
http://www.webassist.com
It will allow you to send both an HTML and a plain text
email. I use it
frequently.
I have an affiliate link on my website, and if you are
interested, please
use that -
http://www.great-web-sights.com
(I am not an employee of WebAssist, but I do use/like their
products)
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"rlinsurf1" <[email protected]> wrote in
message
news:[email protected]...
> I've created what the php manual says should work to
send html mail to our
> customer automatically from the website after a
purchase, along with
> headers to
> send a bcc to us.
>
> But the finished product coming out of DW is a message
body with all the
> code
> tags and headers in the body of the email, not a nice
html email.
>
> I originally created this in GL, and have brought it
over to DW.
>
> Is there maybe a better way to do this?
>
> Here's my code:
>
>
> <?php
>
> $message = '<html>
>
> <head>
> <meta http-equiv="content-type"
content="text/html;charset=utf-8" />
> <style type="text/css" media="all"><!--
> .dsR5 /*agl rulekind: base;*/ { width: 645px; height:
75px; }
> .dsR6 /*agl rulekind: base;*/ { width: 645px; height:
158px; }
> .emailtext { color: gray; font-size: 10pt; font-family:
Verdana, Arial,
> Helvetica, sans-serif; }
> .headertext { color: gray; font-size: 14pt; font-family:
Verdana, Arial,
> Helvetica, sans-serif; font-weight: bold; }
> .ds4 /*agl rulekind: base;*/ { font-size: 15px; }
> .ds10 /*agl rulekind: base;*/ { font-size: 12px; }
> --></style>
> </head>
>
> <body>
> <p><img class="dsR5"
>
src="https://ssl21.pair.com/grndlvl/commerce/gl/images/GRLogo.gif"
alt=""
> border="0" /></p>
> <p class="headertext">Groundlevel Store
Order</p>
> <table class="dsR6" border="0" cellspacing="0"
cellpadding="0">
> <td><span
class="emailtext">Name:</span></td>
> <td class="emailtext"><?php echo $fullname;
?></td>
> </tr>
> <tr>
> <td><span class="emailtext">Email
Address:</span></td>
> <td class="emailtext"><?php echo $email;
?></td>
> </tr>
> <tr>
> <td><span
class="emailtext">Date:</span></td>
> <td class="emailtext"><?php echo $orderdate;
?></td>
> </tr>
> <tr>
> <td><span
class="emailtext">Product:</span></td>
> <td class="emailtext"><?php echo
$item;?></td>
> </tr>
>
> <tr>
> <td><span
class="emailtext">Total:</span></td>
> <td class="emailtext"><?php echo$total;
?></td>
> </tr>
>
> </table>
> <p class="headertext"><span
class="ds4">Thank You for Your
> Order</span></p>
> <p class="headertext"><span class="ds10">You
can expect your order to be
> delivered promptly. You will also receive notifcation of
your shipment
> along
> with the tracking information from the carrier you
selected for delivery,
> either USPS, UPS or Fedex. If you have any questions
about your order,
> please
> email us at:
[email protected].</span></p>
> </body>
>
> </html>';
>
> $headers = 'MIME-Version: 1.0' . "\r\n";
> $headers .= 'Content-type: text/html;
charset=iso-8859-1' . "\r\n";
> $headers .= 'From: Groundlevel Store
<[email protected]>' . "\r\n";
> $headers .= 'Bcc: [email protected]' . "\r\n";
>
>
> mail($email,"Your Groundlevel Store Order",$message,
$headers) // this
> line is
> the ending tag
>
> ?>
>
Maybe you are looking for
-
Get Support link does not work after SPS13 installation
Good evening, we have patched our system from NW7 SPS10 to NW7 SPS13. We have problem with our portal: on home page Get Support Link doesn't work! When user click on Get Support link doesn't happen, only web page change from https://sitemane/irj/port
-
MY 2YR OLD LOCKED AN IPHONE 3GS THAT HAS NO SIMS CARD I TRIED ALL KIND OF PASSWORDS IT LOKED ME OUT FOR 15 MINS IS THE PASSWORD THE LAST PASSWORD SET ON THE PHONE
-
I exported a pdf file to word, now every pdf file I have has automatically changed to word. I cannot even save a pdf file now, it just saves as a word document ?
-
SPECIAL1 user defined Trigger not firing in Forms
Hi All forms Gurus, I have a need of creating a menu under tools in forms and call another from from this new menu option. I have done the below: on my block I have written a PRE-BLOCK Trigger with the below code: app_special.instantiate('SPECIAL1',
-
Mails are in Waiting status in SOST
Hello, During production monitoring the mails in SOST transaction were in waiting Status. Kindly suggest me how to administer the cause of it and how to trace it. Regards, Akshay