HTML email with JSP

Hi I've been working an an email bean for some time now. I have got almost everything working. I am just getting hung up on formating the email. I want my email to be in HTML so that I have more control over the formating. To that end my message is set up as
msg.setContent(message, "text/html"); in my class file.
My JSP page is as follows.
<html>
<%@ page import="sendmail.SendMail"%>
<body>
<%String to = "[email protected]";%>
<%String from = "[email protected]";%>
<%String subject = "Test E-Mail through JSP";%>
<%String message = "<h1>This is a test of sending a  plain text e-mail through JSP.</h1><br> Here is line 2.";%>
<jsp:useBean id="sendEmail" class="sendmail.SendMail" scope="session">
<jsp:setProperty name="sendEmail" property="to"  value="<%=to%>" />
<jsp:setProperty name="sendEmail" property="from"  value="<%=from%>" />
<jsp:setProperty name="sendEmail" property="subject"  value="<%=subject%>" />
<jsp:setProperty name="sendEmail" property="message"  value="<%=message%>" />
</jsp:useBean>
<%
sendEmail.sendEmail();
%>
The page displayed.  Did the email send?
</body>
</html>The email that this page is sending is in HTML format, but the formating is not evident in the message. I'm sure that I'm missing something very minor but for the life of me I can't figure it out. Any help would be appriciated. Thanks.
Never mind. It turns out that this was caused by me seting the bean to a session type. When I stopped and started Tomcat it worked fine. So I changed the bean to request and it is working fine now.
Edited by: Millisa on Apr 30, 2008 9:55 AM

Try this
<%@ page import="sun.net.smtp.SmtpClient,java.io.PrintStream" %>
<%
try{
String host = "IP"; //this is u r IP adress
String from = "[email protected]"; //mail adress of sender
String to = "[email protected]"; //mail address whom to
SmtpClient smtp = new SmtpClient(host);
smtp.from(from);
smtp.to(to);
PrintStream out1 = smtp.startMessage();
out1.println("To: " + to);
out1.println("Subject: Hello peter ");
out1.println();
out1.println("Hi Peter How r u doing ");
out1.flush();
out1.close();
smtp.closeServer();
catch(Exception e)
out.println(e+e.getMessage());
%>

Similar Messages

  • Sending a html email with jsp

    is it possible to send an email with html content and how do i do that

    Try this
    <%@ page import="sun.net.smtp.SmtpClient,java.io.PrintStream" %>
    <%
    try{
    String host = "IP"; //this is u r IP adress
    String from = "[email protected]"; //mail adress of sender
    String to = "[email protected]"; //mail address whom to
    SmtpClient smtp = new SmtpClient(host);
    smtp.from(from);
    smtp.to(to);
    PrintStream out1 = smtp.startMessage();
    out1.println("To: " + to);
    out1.println("Subject: Hello peter ");
    out1.println();
    out1.println("Hi Peter How r u doing ");
    out1.flush();
    out1.close();
    smtp.closeServer();
    catch(Exception e)
    out.println(e+e.getMessage());
    %>

  • When I forward an HTML email with embedded graphics to someone, it forwards it as plain text.. this is driving me batty.. how do I forward such mails INTACT??

    I have the latest Thunderbird installed on a new 64-bit Winblows Eight netbook.. fantastic program, but one problem is driving me absolutely batty, and after using the latest Thunderbird for weeks, I simply can't figure out how to fix it..
    I'm on a lot of mfr. and other kinds of mailing lists, like eBay watch list alerts, and so on.. these are not s p a m (although I get plenty of that.. who doesn't).. but lists I WANT to be on..
    Many such emails from those mailing lists are in HTML format with embedded graphics.. I'm not talking about graphic file attachments, but embedded graphics which are coming from the senders' servers, and appear AS a graphic in the email.. sometimes such emails are one huge graphic with hardly any text.. all well and good..
    However, here's the problem.. when I want to forward such an email to a friend, Thunderbird ALWAYS formats it as plain ASCII text.. I know this because I look in the "sent mail" folder, and can see that it has turned an HTML email with embedded graphics into plain ASCII text..
    I absolutely can't figure out how to get it to forward an HTML email with embedded graphics INTACT, so the sender receives it looking the way it looks when I receive it from a mailing list, or an advertiser, or eBay, or whoever..
    Is Thunderbird capable of forwarding an HTML email with embedded graphics INTACT?.. If so, how / where do I turn on that capability?..
    If the capability to do this isn't built into the program, is there an add-on I can install that will give it that ability?..
    I am not new to computers.. but this really has me stumped.. I want to put Thunderbird on my 32-bit Vista laptop and stop using its horrible "Windoze Mail" program, which I've been using for years, and is slower than snot, and has all kinds of other problems..
    So, assuming whoever reads this FULLY understands my question, PLEASE tell me how to get Thunderbird to have the ability to forward an HTML email with embedded graphics AS-IS, so the receiver(s) I forward it to see it exactly the way I see it when I receive it.. if that ability is built in, please tell me how to turn it on.. if that ability is not built-in, please tell me what add-on I need to install to give Thunderbird this capability.. if Thunderbird absolutely can't forward an HTML email with embedded graphics at all, please also tell me that..
    A virtual box of candy and a dozen long-stemmed roses to anyone who can give me a solution that works..
    Thanks..

    Dear Mr. Toad (my all-time favorite ride at Disneyland ;-) ..
    Thanks so much for your detailed reply.. my netbook is in the bedroom, turned off.. I (so far) only use it in the evening, in the bedroom.. I've saved your response, and will try your suggestions, and let you know if they solve the problem I described. I really appreciate you taking the time to post such a detailed reply..
    I can't answer your Thunderbird "configuration" questions, because I'm in the living room, using the crap Vista laptop, on which I plan to install Thunderbird, and then take Windoze Mail out in the street and drive over it a few times.. I'll get back to you one way or the other, and let you know if your instructions solved the problem, or not..
    I don't understand why Thunderbird "out of the box", so to speak, simply doesn't forward HTML emails with embedded graphics, (like Outlook Excess, and Winblows Mail do).. without having to go through those steps. I personally HATE HTML email, but over the years, it's become more and more prevelant.. so it's a problem I must fix..
    Thanks again..
    Harv..

  • HTML emails with attachments

    When I compose an html email (ie: using the float left alignment on a picture) and add an attachment(word doc), the formatting is lost on the recipient's end. In fact usually, the body of the message is blank and the pictures, html file, and original attachment all show up as attachments. I'm wondering if this is an undocumented limitation of Mail or if I'm doing something wrong. I know that when you compose a mail using stationery you can't add any attachments.
    The formatting isn't even correct in Mail's sent folder (show up as rich text similar to Mail 2's formatting). Is anyone out there able to send an html email with an attachment?
    ~Ryan

    It looks like there is an actual RFC for HTML e-mail. It is a bit more "standard" than I thought. When I looked at the raw messages last night, they didn't look like other HTML MIME messages I had worked with in the past. If I can provide that Apple Mail doesn't conform to this RFC, I will update the bug report with the details. In the past, Apple has been very good with e-mail standards - years ahead of everyone else. I certainly hope the format of the message is correct and it is just a display problem.

  • Sending HTML email with SO_DOCUMENT_SEND_API1

    Hi all,
    I have implemented a function module to send HTML emails with SO_DOCUMENT_SEND_API1.
    It works fine, but in every email I have at the end a CRLF which looks not very nice in MS Outlook.
    It seems that this will be added to every email in addition to my HTML text.
    Has anyone an idea how I can prevent this?
    Thanks in advance for your help.
    Best Regards,
    Marcel

    Hi Marcel,
    not only you can, you should use CL_BCS for sending of email. Although I expect it to be not too different from the old functions, it points to the object oriented future of SAP/ABAP. At least it should run more stable and SAP recommends to use it as a replacement for old functions.
    I came across one blog
    [Sending HTML Email from SAP CRM/ERP|http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=%28J2EE3417300%29ID2058700050DB10227264795501776639End?blog=/pub/wlg/2273]
    You may be careful with this one: Probably it's not exactly what you need.
    The one I love most for its simplicity is this one
    [Unknown thus unloved?|http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=%28J2EE3417300%29ID2058700050DB10227264795501776639End?blog=/pub/wlg/3443]
    although it does not mention HTML - I think easy for you to adapt. Compared  to functional SO_DOCUMENT.. approach the program will shrink.
    If you want to understand the concepts behind, nobody explains it better than
    [Thomas Jung: Sending E-Mail from ABAP - Version 610 and Higher - BCS Interface|http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=%28J2EE3417300%29ID2058700050DB10227264795501776639End?blog=/pub/wlg/789]
    or - if you still feel unsafe in oo environment -
    [Sending E-Mail from ABAP - Version 610 and Higher - BCS Interface|http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=%28J2EE3417300%29ID2058700050DB10227264795501776639End?blog=/pub/wlg/15408]
    Happy coding!
    Regards,
    Clemens

  • Html email with blob attachment and authentication

    I have been looking for a plsql package to send html emails with blob attachments. The html portion and the blob attachment are more than 32k.
    Also the email server needs to be authenticated.
    Does anyone know of something already written to do this? I’ve found lots of code that does one or two items but not all.
    Must:
    - Authenticate
    - Html email
    - Accept blob as input parameter for attachment
    - Exceed 32k
    There are so many routines, I’ve been searching looking for one which does all.

    This works for authentication:
    utl_smtp.command(l_mail_conn, 'AUTH LOGIN' );
    utl_smtp.command(l_mail_conn,utl_raw.cast_to_varchar2(utl_encode.base64_encode(utl_raw.cast_to_raw ( v_username ))));
    utl_smtp.command(l_mail_conn,utl_raw.cast_to_varchar2(utl_encode.base64_encode(utl_raw.cast_to_raw ( v_password ))));

  • Is there a video tutorial available on creating an html email with dreamweaver

    Is there a video tutorial available on making an html email with dreamweaver?

    Hello Warren,
    Currently we do not offer a video on this topic; all of our getting started videos currently available can be seen at: http://helpx.adobe.com/creative-cloud/learn/start.html.  That's not to say a video such as the one you are looking for doesn't exist out in the wild somewhere, but we have not produced any content on that particular topic.
    However, we're just getting started (no pun intended ) so feedback like yours is valuable as we consider future topics to focus our getting started projects on.
    Thank you for your input.
    Ed Sullivan

  • Can't create dynamic html elements with jsp????? important

    Hi All,
    I am having problem creating dynamic html elements with jsp tags, i have tried to use EL and java scriplet, both of them don't work.
    i am trying to create dynamic menu in my "rightMenu.jspf", based on, if user has logged in or not.
    some like this!
    <jsp:if test ="${validUser == null}">
    some simple text menu here
    </jsp:if>
    but it is not working. it simply loading all and images with in statement, regardless of whether user has logged in or not. i think some how if statement is not working properly.
    "validUser" is a session bean, which is not creating at this point, it will created when user will log in successfully. and also this session bean does not exist at the page, where i am trying to check that .
    Is there any way to create dynamic values in jsp. It is really important, is there any body who help me in this matter. i would be really grateful.
    zaman

    hi jaspre,
    thanks for replying me. you know what, is it not something wrong with web.xml file. i remember once, i deleted some from there, a property with "*.jsp". i can't remember what exactly was it though.
    all if statements works on files ending with extension ".jsp" but don't work only on with extension ".jspf". there must be to do with this.
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <servlet>
    <servlet-name>ValidateServlet</servlet-name>
    <servlet-class>ValidateServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ValidateServlet</servlet-name>
    <url-pattern>/ValidateServlet</url-pattern>
    </servlet-mapping>
    <servlet>
    <servlet-name>dwr-invoker</servlet-name>
    <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
    <init-param>
    <param-name>debug</param-name>
    <param-value>true</param-value>
    </init-param>
    <init-param>
    <param-name>pollAndCometEnabled</param-name>
    <param-value>true</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
    <servlet-name>dwr-invoker</servlet-name>
    <url-pattern>/dwr/*</url-pattern>
    </servlet-mapping>
    <session-config>
    <session-timeout>
    30
    </session-timeout>
    </session-config>
    <welcome-file-list>
         <welcome-file>
    main.jsp
    </welcome-file>
    </welcome-file-list>
    </web-app>
    if any one can figure it out. i would be grateful.
    zaman

  • Send HTML emails with ODI

    Hi,
    I wish to send HTML emails with ODI but it seems not possible with the tool ODISendMail. Do you know a procedure to do it ?
    Thank you very much for your answers.
    Regards.

    Hello,
    Thanks but this article decribes an other tool that I don't have in my version. Maybe is it possible to send me the procedure XML to import it ?
    There is also a procedure available on the Oracle support (TRT_Send_Jython_HTML_Email.xml) but I don't know where I can download it... Do you ?
    Thank you very much

  • How to send HTML emails with embedded graphics?

    I've discovered Mail is great for sending HTML if you open it in Safari and select "Mail Contents of this Page" - - My problem is, I need to include the graphic elements as embedded images rather than hosted images.
    Is there any way to do this with Mail.app?
    Can I somehow modify my HTML image references to make this happen?
    Is there another Mac application recommended to do this?

    The best thing I've tried is Max Bulk Mailer. Do a search for it on VersionTracker. It's about $50. or so.
    If you're just looking to send one offs, you can do it with a hotmail account - just make sure you pull out the doctype tag (you should do this for any html email).

  • Creating html email with apple's mail

    How do i get an html page (created in Dreamweaver) to show up in apple's mail window?
    I want the html page to display. If I just attach the html file all I get is an icon of the file not the look of the html file (ie with background color and placed photo and html text). I know to have the placed image with an absolute reference (ie. http://www.whatever.com/image.jpg)

    Tiger Mail uses Apple's new WebKit authoring engine, creating complex HTML email messages with Mail's trademark simplicity. However, most of the power of that engine is inaccessible. Aside from the addition of an "Add Hyperlink…" menu item, Mail's composition window offers no better text or layout controls than 10.0's Mail did in 2001.
    Tiger was replaced by Leopard last October, and Leopard Mail has a new feature called Stationery which might provide some of what you are talking about:
    http://www.apple.com/macosx/features/mail.html

  • UTL_SMTP send HTML email with embedded image?

    Hi, I can use UTL_SMTP to send an HTML email ok, but does anyone have an example of how to include an inline embedded image in the email? Thanks!

    If you want to send the html page and have it
    reference the images and css files on your web
    site, that's pretty easy. Just create a message
    with text/html content that is your html page.
    If you want to include all the images and css files
    in your message along with the html page, you'll
    need to create a multipart/related message and
    you'll need to change all the html to reference the
    images and css files using "cid:" references.

  • Dynamic HTML elements with JSP?

    I need to have a row in a HTML page which contains of a combox and two text fields.
    Depending on what I select in the combox I have to insert another row (which contains another combox and two text fields) or I have to remove one or both text fields from the current row.
    Is that possible with JSP?
    Many thanks

    You can certainly accomplish what you're asking for in a jsp. One of the tricks you can use to solve your problem would be to pass variables back into the page using the Get method and catching the values using the request.getParameter() technique. One quick tip, you should wrap any request.getParameter() elements with a try catch, if you try to grab a parameter that hasn't been defined yet (and this is perfectly acceptable) you'll get a null returned.
    I hope this helps

  • Building HTML page with JSP from different applications

              Hi,
              we need to build a HTML page with 2 JSPs. If both JSP were in the same Application
              (Weblogic 8,1) there is no problem. But I have to use JSPs from differents web
              applications, each JSP is in different war files.
              How can I compose this page? How can I management the request object?
              thanks
              

    Your program print the whole jsp source code??
    This is your web server configuration problem.
    Your web server handle your jsp page like text file only.

  • HTML-FRAMES with jsp as sorce

    Hi,
    I use a HTML with 5 FRAMES, 2 of them with jsp-files as src.
    How can I pass data to these jsp-files before the servlet calls the HTML?
    Is this possible at all?
    Thanks a lot

    you can reference and set hidden input values inside another frame by referencing them in javascript function. afterwards, submit the form ...
    function submitInfo() {
    top.frames["frameName"].document ... // branch for NS and IE
    document.forms["currentForm"].submit();
    }

Maybe you are looking for