How to send mail in html format in jsp???
Hello everybody,
I have two jsp pages.In one page I have the heading like Date,Transaction.I am retriving data from my second jsp page.And I hae included the second jsp page to my first jsp page.How to send mail this content in html format.
Thanks
Srikant
MimeMessage m = new MimeMessage(session);
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setContent(content, "text/html");this if u need to send a mail content as html
Similar Messages
-
How to send mail in HTML format using SMTP
I want to send mail in HTML format using SMTP.Can anybody please suggest how to do it.Can anybody send me the code.
Thnx.If you don't know how to send a message using JavaMail see here : http://developer.java.sun.com/developer/onlineTraining/JavaMail/contents.html#JavaMailSending
To send a html format mail you need to set the content type like this (msg is a javax.mail.internet.MimeMessage) :
String subject = "An Email 4 U";
String message = "<HTML><BODY>Here is a link<br><a href='http://javasoft.com'>Java</a></BODY></HTML>";
msg.setSubject(subject);
msg.setContent(message, "text/html");p.s This isn't really an advanced topic -
How to send mails in HTML format from the send mail step of workflow?
Hi,
I have a requirement where I need to send mails in the html format from the send mail step of the workflows.
But what I found out that the html tags are not renderd and as such the output is in plain text.
I know that there is an alternative of using an activity step and use my own custom code from within there,But due to certain business constraints, I need to use the send mail step only.
My SCOT settings are all right.
Please let me know how it can be done.
Thanks,
Samrat.Samrat,
It can't be done, you have to use your own activity step.
What are these constraints that refrain you from doing that?
Rgds,
Patrick -
How to send mail using HTML format using tags
Hello experts,
I am currently using FM SO_NEW_DOCUMENT_SEND_API1 to send e-mails to our users' Outlook accounts. Now, I converted its document type from 'RAW' to 'HTM'. I enclosed my texts in HTML tags. But the problem is, I cannot see a thing when I check my message in SCOT. It just opens internet explorer and thats it. Anyway, Below is my code:
get e-mail addresses of controllers in table ZSHIPTO_EMAIL
SELECT * FROM zshipto_email
INTO TABLE it_zshipto_email
WHERE zevent = '2'.
IF sy-dbcnt > 0.
IF NOT it_del_entries[] IS INITIAL.
CLEAR lv_contents.
maildata-obj_name = 'Record Deleted in table ZTS0001'.
maildata-obj_descr = 'Record Deleted in table ZTS0001'.
maildata-obj_langu = sy-langu.
records deleted in ZTS0001 and ZTS_STPGEOLOC
CLEAR: lv_flag, lv_counter.
LOOP AT it_zshipto_email.
CLEAR: it_del_entries, mailtxt.
LOOP AT it_del_entries ASSIGNING <fs_del_entries>.
get name of dealer
SELECT SINGLE name1 FROM kna1
INTO <fs_del_entries>-name1
WHERE kunnr = <fs_del_entries>-kunnr.
IF lv_counter IS INITIAL.
CONCATENATE: '<p>'
'FYI: The ff record/s were deleted in tables'
'ZTS0001 and ZTS_STPGEOLOC by user' sy-uname
'</p>'
INTO lv_contents
SEPARATED BY space.
mailtxt-line = lv_contents.
APPEND mailtxt.
CLEAR: mailtxt, lv_contents.
ENDIF.
APPEND mailtxt.
CONCATENATE: '<p>'
'Dealer :' <fs_del_entries>-kunnr '-'
<fs_del_entries>-name1 '</p>'
INTO lv_contents
SEPARATED BY space.
mailtxt-line = lv_contents.
APPEND mailtxt.
CLEAR: mailtxt, lv_contents.
CONCATENATE: '<p>'
'Ship-To:' <fs_del_entries>-cdseq '</p>'
INTO lv_contents
SEPARATED BY space.
mailtxt-line = lv_contents.
APPEND mailtxt.
CLEAR: mailtxt, lv_contents.
CONCATENATE: '<p>'
'Address:' <fs_del_entries>-zaddress '</p>'
INTO lv_contents
SEPARATED BY space.
mailtxt-line = lv_contents.
APPEND mailtxt.
CLEAR: mailtxt, lv_contents.
CONCATENATE: '<p>'
'Contact person:' <fs_del_entries>-zcperson
'</p>'
INTO lv_contents
SEPARATED BY space.
mailtxt-line = lv_contents.
APPEND mailtxt.
CLEAR: mailtxt, lv_contents.
CONCATENATE: '<p>'
'Contact number:' <fs_del_entries>-zcnumber
'</p>'
INTO lv_contents
SEPARATED BY space.
mailtxt-line = lv_contents.
APPEND mailtxt.
CLEAR: mailtxt, lv_contents.
lv_counter = 1.
ENDLOOP.
APPEND mailtxt.
mailrec-receiver = it_zshipto_email-zemail.
mailrec-rec_type = 'U'.
APPEND mailrec.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = maildata
document_type = 'HTM'
put_in_outbox = 'X'
commit_work = 'X'
TABLES
object_header = mailtxt
object_content = mailtxt
receivers = mailrec
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR: mailtxt, mailrec, lv_counter.
REFRESH: mailtxt, mailrec.
ENDLOOP.
ENDIF.
Message was edited by: viraylabHi,
Check this...
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5931ff64-0a01-0010-2bb7-ff2f9a6165a0
Regards
vijay -
Send mail in HTML Format in Service Desk
Dear Friends,
We want to send email in html format to every user in service desk, how can we figure it?
Thanks in advance
Regards,Hello Eray,
You will want to have a look at this document and hopefully it will assist you accomplish what you need.
http://service.sap.com/~sapidb/011000358700001903822008E
Regards,
Paul -
Is it possible with ODISendMail to send mail not in simple text but in HTML?
If no... how can I do that?If you are looking for capturing the error in the HTML format that can be done by using odioutfile and save the file as HTML and use the required command at the message tab to capture the error .
in the Next step use - odisendmail attach the above html file as attached. -
How to send information from HTML page to JSP without reloading HTML page?
Hello,
Is it possible to send information(row number selected by user) from HTML page to JSP without reloading HTML page?
Thanks.
Oleg.Yes, you can do this with framesets and a hidden frame.
You need a bit of JavaScritp in the "visible" frame that
sets the location of the hidden frame to the JSP.
Add the user's choice as a parameter to the JSP URL. -
How to send mail using Java Server Pages(JSP)
Plz reply me the code for it
and send me mailmegha_bhagat82: You've posted 3 ill-defined questions in the wrong forum in 4 minutes on the day you registered: I suggest you take a very close look at http://www.catb.org/~esr/faqs/smart-questions.html ... I usually avoid posting that URL to often, as it can be considered rude, but I think in your case it's appropriate.
-
Hi All,
My requirement is to send emails. I am using javamail and it works fine. But the body of the email should be in table format.
I am planning to use Html as below. But don't know how to combine html in java. Is there any other way of achieving it ? Please let me know if I am not clear.
<htm>
<table border="1">
<tr>
<td bgcolor="red">Header</td>
</tr>
<tr>
<td bgcolor="yellow">Sub Header1</td>
<td bgcolor="yellow">Sub Header1</td>
</tr>
<tr>
<td bgcolor="green">Values</td>
<td bgcolor="green">Values</td>
</tr>
</html>so, do I need another method which tells Java whereto output the HTML Tags ?
The method writes to a PrintWriter defined somewhere,
you can also pass the PrintWriter as third argument
to the method.
To generate a String containg the whole HTML Dokument
you would write something like:
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new
PrintWriter(stringWriter);
writeStartTable();
writeStartRow();
writeCell("BlaBla", "green");
printEndTable();
printWriter.flush();
printWriter.close();
stringWriter.close();
String content = stringWriter().toString();
BodyPart mailBody = new MimeBodyPart();
mailBody.setContent(content, "text/html");
I was succesful in sending mail using HTML format. Thanks for ur reply.
But if I try send the mail in HTML format along with an attachment, the MIME type defaults to "text/plain".
Is there a way to set the MIME type to "text/html" when I send mail with an attachment.
Please help . Let me know if I am not clear -
How to send a mail in html format from a send mail workflow node ?
Dear all,
Do you know if it is possible to send an e-mail in HTML format (instead of RAW) from a "send mail" node in a workflow ? ... if "yes", please, let me know.
(I need to do that because I want to use the "href" tag to insert an hyperlink inside the e-mail)
- I haven't found any parameter to specify the format of the e-mail.
- Inside SCOT I tried to change the parameters for the SMTP node... without success.
- I don't want to use a task calling the FM SO_OBJECT_SEND.
NicolasHi 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 -
How to send program output as mail in HTML format
Hi Friends,
I have a BDc which runs in background and its been Stored in my system and displayed as HTML format.
My requirement is now i want that Same HTML file which i am displaying to be sent as a mail in HTML format itself..Kindly help me on this
Thanks in advance
kishoreHi,
Below sample program might give you idea on sending HTML attachment.
TYPES: BEGIN OF t_sal_ord,
vbeln TYPE vbeln_va,
posnr TYPE posnr_va,
auart TYPE auart,
vkorg TYPE vkorg,
matnr TYPE matnr,
END OF t_sal_ord.
DATA: i_sal_ord TYPE STANDARD TABLE OF t_sal_ord,
i_header TYPE STANDARD TABLE OF w3head,
i_fields TYPE STANDARD TABLE OF w3fields,
i_html TYPE STANDARD TABLE OF w3html,
wa_header TYPE w3head.
DATA: i_fcat TYPE lvc_t_fcat,
wa_fcat TYPE lvc_s_fcat.
DATA: g_send_request TYPE REF TO cl_bcs,
g_document TYPE REF TO cl_document_bcs,
g_recipient TYPE REF TO cl_cam_address_bcs,
g_cx_bcs TYPE REF TO cx_bcs,
g_sent_to_all TYPE os_boolean.
DATA: g_lines TYPE i,
g_size TYPE so_obj_len.
PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY,
p_mailad TYPE ad_smtpadr OBLIGATORY.
START-OF-SELECTION.
SELECT a~vbeln b~posnr a~auart a~vkorg b~matnr
INTO TABLE i_sal_ord
UP TO 20 ROWS
FROM vbak AS a
INNER JOIN vbap AS b
ON a~vbeln = b~vbeln
WHERE a~vkorg = p_vkorg.
wa_fcat-coltext = 'SalesOrd#'.
APPEND wa_fcat TO i_fcat.
wa_fcat-coltext = 'Item#'.
APPEND wa_fcat TO i_fcat.
wa_fcat-coltext = 'OrdType'.
APPEND wa_fcat TO i_fcat.
wa_fcat-coltext = 'Sales.Org'.
APPEND wa_fcat TO i_fcat.
wa_fcat-coltext = 'Material'.
APPEND wa_fcat TO i_fcat.
LOOP AT i_fcat INTO wa_fcat.
wa_header-text = wa_fcat-coltext.
CALL FUNCTION 'WWW_ITAB_TO_HTML_HEADERS'
EXPORTING
field_nr = sy-tabix
text = wa_header-text
size = '2'
fgcolor = 'BLACK'
bgcolor = 'VIOLET'
font = 'CALIBRI'
TABLES
header = i_header.
CALL FUNCTION 'WWW_ITAB_TO_HTML_LAYOUT'
EXPORTING
field_nr = sy-tabix
size = '2'
fgcolor = 'BLACK'
bgcolor = 'WHITE'
font = 'CALIBRI'
TABLES
fields = i_fields.
ENDLOOP.
wa_header-text = 'Sales Order Details'.
wa_header-size = '2'.
wa_header-font = 'CALIBRI'.
CALL FUNCTION 'WWW_ITAB_TO_HTML'
EXPORTING
* TABLE_ATTRIBUTES = 'BORDER=1'
table_header = wa_header
* ALL_FIELDS = 'X'
TABLES
html = i_html
fields = i_fields
row_header = i_header
itable = i_sal_ord.
TRY .
g_send_request = cl_bcs=>create_persistent( ).
g_document = cl_document_bcs=>create_document(
i_type = 'RAW'
* i_text = i_content[] " Body for Mail
i_subject = 'Sales Order Details' ).
DESCRIBE TABLE i_html LINES g_lines.
g_size = g_lines * 2 * 255.
CALL METHOD g_document->add_attachment
EXPORTING
i_attachment_type = 'HTM'
i_attachment_subject = 'Sales Order Details'
i_attachment_size = g_size
i_att_content_text = i_html[].
g_send_request->set_document( g_document ).
g_recipient = cl_cam_address_bcs=>create_internet_address( p_mailad ).
g_send_request->add_recipient(
EXPORTING
i_recipient = g_recipient
i_express = 'X' ).
g_send_request->set_send_immediately( 'X' ).
g_send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = g_sent_to_all ).
COMMIT WORK.
CATCH cx_bcs INTO g_cx_bcs.
WRITE:/ g_cx_bcs->error_type.
ENDTRY.
Kind Regards
Eswar -
Java.mail sending email in html format
I trying to send emails from my java program, I ve managd to send text mails, I want to send email in html format is there a way of doing that and how
thanks for your helpThanks a lot it is working now but I think that sending mails in text format is the best way since there isn't a way of knowing whether the recepient can handel html mails
-
How to send Mailing Spool Details of Background jobin EXCEL format
Dear All,
Hope every one doing awesome.
As per client requirement we need to send spool detail to user in EXCEL format.
http://sapignite.com/sending-mail-for-background-job/
As per the mentioned thread ABAPER created the code and we are getting mails in HTML format.
Now the user wants the files in EXCEL format.
I had checked in SCOT and doesn't found any useful setting that will make the required changes.
Any other suggestion ?
Tons of thanks for your support.
Regards
Nikhilneed solution..
-
Send e-mail in HTML-format with attachment
Does function SO_OBJECT_SEND allow to send e-mail with attachment?
Does function SO_DOCUMENT_SEND_API1 allow to send e-mail in HTML format?Hi SS
See if you can understand this sample program
PARAMETERS: po_email TYPE AD_SMTPADR LOWER CASE.
DATA: li_objcont TYPE STANDARD TABLE OF solisti1,
li_reclist TYPE STANDARD TABLE OF somlreci1,
li_objpack TYPE STANDARD TABLE OF sopcklsti1,
li_objhead TYPE STANDARD TABLE OF solisti1,
li_content TYPE STANDARD TABLE OF solisti1,
lwa_objcont TYPE solisti1,
lwa_reclist TYPE somlreci1,
lwa_objpack TYPE sopcklsti1,
lwa_objhead TYPE solisti1,
lwa_content TYPE solisti1,
lwa_doc TYPE sodocchgi1,
l_lines TYPE i.
REFRESH: li_objcont[], li_reclist[],
li_objpack[], li_objhead[],
li_content[].
CLEAR: lwa_objcont, lwa_reclist,
lwa_objpack, lwa_objhead,
lwa_content, lwa_doc.
MOVE '<body>' TO lwa_objcont.
APPEND lwa_objcont TO li_objcont.
MOVE '<p>' TO lwa_objcont.
APPEND lwa_objcont TO li_objcont.
MOVE 'This is a sample HTML content from test program' TO lwa_objcont.
APPEND lwa_objcont TO li_objcont.
MOVE '</p>' TO lwa_objcont.
APPEND lwa_objcont TO li_objcont.
MOVE '</body>' TO lwa_objcont.
APPEND lwa_objcont TO li_objcont.
lwa_reclist-receiver = po_email.
lwa_reclist-rec_type = 'U'.
APPEND lwa_reclist TO li_reclist.
lwa_objhead = 'test.htm'.
APPEND lwa_objhead TO li_objhead.
lwa_content = 'Please find attached document for more details'.
APPEND lwa_content TO li_content.
CLEAR l_lines.
DESCRIBE TABLE li_content LINES l_lines.
READ TABLE li_content INTO lwa_content INDEX l_lines.
lwa_doc-doc_size = ( l_lines - 1 ) * 255 + STRLEN( lwa_content ).
lwa_doc-obj_langu = 'E'.
lwa_doc-obj_name = 'Test HTML file'.
lwa_doc-obj_descr = 'Test HTML file'.
CLEAR lwa_objpack-transf_bin.
lwa_objpack-head_start = 1.
lwa_objpack-head_num = 0.
lwa_objpack-body_start = 1.
lwa_objpack-body_num = l_lines.
lwa_objpack-doc_type = 'RAW'.
APPEND lwa_objpack TO li_objpack.
CLEAR: lwa_objpack, l_lines.
DESCRIBE TABLE li_objcont LINES l_lines.
READ TABLE li_objcont INTO lwa_objcont INDEX l_lines.
lwa_objpack-doc_size = ( l_lines - 1 ) * 255 + STRLEN( lwa_objcont ).
lwa_objpack-transf_bin = 'X'.
lwa_objpack-head_start = 1.
lwa_objpack-head_num = 0.
lwa_objpack-body_start = 1.
lwa_objpack-body_num = l_lines.
lwa_objpack-doc_type = 'HTM' .
lwa_objpack-obj_name = 'Test HTML file'.
lwa_objpack-obj_descr = 'Test HTML file'.
APPEND lwa_objpack TO li_objpack.
*Sending the mail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = lwa_doc
put_in_outbox = 'X'
TABLES
packing_list = li_objpack
object_header = li_objhead
contents_bin = li_objcont
contents_txt = li_content
receivers = li_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc NE 0.
WRITE:/ 'Document sending failed'.
ELSE.
WRITE:/ 'Document successfully sent'.
COMMIT WORK.
ENDIF.
This should give you all you need to know to send an HTML file.
Thanks buddy -
How can send mails using hotmail/rediffmail domain name?
I have used the below code to send a mail using javamail API?Even when I am sending my application does not have notified any of error/exceptions,But the message is not reached to I have given receipient's address in the to field.
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class Sendmail1 extends HttpServlet {
private String smtpHost;
// Initialize the servlet with the hostname of the SMTP server
// we'll be using the send the messages
public void init(ServletConfig config)
throws ServletException {
super.init(config);
smtpHost = config.getInitParameter("smtpHost");
//smtpHost = "sbm5501";
smtpHost = "www.rediffmail.com";
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException, java.io.IOException {
String from = request.getParameter("from");
String to "[email protected]";
String cc = "[email protected]";
String bcc ="[email protected]";
String smtp ="www.rediffmail.com";
String subject = "hai";
String text = "Hai how r u";
PrintWriter writer = response.getWriter();
if (subject == null)
subject = "Null";
if (text == null)
text = "No message";
String status;
try {
// Create the JavaMail session
java.util.Properties properties = System.getProperties();
if (smtp == null)
smtp = "www.rediffmail.com";
properties.put("mail.smtp.host", smtp);
Session session = Session.getInstance(properties, null);
//to connect
//Transport transport =session.getTransport("smtp");
//transport.connect(smtpHost,user,password);
// Construct the message
MimeMessage message = new MimeMessage(session);
// Set the from address
Address fromAddress = new InternetAddress(from);
message.setFrom(fromAddress);
// Parse and set the recipient addresses
Address[] toAddresses = InternetAddress.parse(to);
message.setRecipients(Message.RecipientType.TO,toAddresses);
Address[] ccAddresses = InternetAddress.parse(cc);
message.setRecipients(Message.RecipientType.CC,ccAddresses);
Address[] bccAddresses = InternetAddress.parse(to);
message.setRecipients(Message.RecipientType.BCC,bccAddresses);
// Set the subject and text
message.setSubject(subject);
message.setText(text);
Transport.send(message);
//status = "<h1>Congratulations,</h1><h2>Your message was sent.</h2>";
} catch (AddressException e)
status = "There was an error parsing the addresses. " + e;
} catch (SendFailedException e)
status = "<h1>Sorry,</h1><h2>There was an error sending the message.</h2>" + e;
} catch (MessagingException e)
status = "There was an unexpected error. " + e;
// Output a status message
response.setContentType("text/html");
writer.println("<title>sendForm</title><body bgcolor= ><b><h3><font color=green><CENTER>CALIBERINFO.COM</CENTER></h3>Your message was sent to recepient(s).<br><font color=red>"+"\n"+to);
writer.println("<br><br><a href=e:/mail/javamail/mail.html>back to compose</a>");
writer.close();
Please any one help me out from this probs.
Awaiting for yours reply,
or give me a reply to: [email protected]
Regards,
@maheshkumar.kHi,
how can send mails using hotmail/rediffmail domain name?In your java application,you specified www.rediffmail.com as your
smtp server.But that is the address of that website.Try will a smtp
server instead.For a list of free smtp servers,please visit http://www.thebestfree.net/free/freesmtp.htm
Hope this helps.
Good Luck.
Gayam.Srinivasa Reddy
Developer Technical Support
Sun Microsystems
http://www.sun.com/developers/support/
Maybe you are looking for
-
I just installed to the labview 2011, and many other modules and softwares including this VASAugust2010. But the IMAQdx is missing from the function palette (vision and motion). However the NI-IMAQ 4.5, IN-IMAQ IO 2.4.0 and NI-IMAQdx 3.7 are all clea
-
Trouble with Materialized View
Hello, I'm in need of some help enforcing data integrity using a materialized view. In my example, each system may consist of three types of components and this is modeled using supertype/subtype relationships. I'm trying to enforce that, for a given
-
Downloading Oracle R12 for windows from edelivery
Hi, I would like to Download Oracle R12 for windows from edelivery.oracle.com I am selecting Oracle 12 for windows. Then i get about 25 options to Download. How many should i Download for complete Oracle R12 software and do i need to create Directory
-
Hi all, I'm writing because for the past few days my iMac G5 has been doing this weird thing during startup. It kinda looks like the screen's shaking and a lot of static/snow comes up on the screen. Once it logs in the folders on the desktop look dis
-
I have made a web browser, when you load a web-page a progress bar is displayed showing the current progress of the page loading. However if you try and load a new page before the previous page has finished loading the progress bar goes crazy. I have