HTML messages with SMTPClient

I'm trying to send HTML messages using the older SMTPClient class that comes with the earlier JDK's. I use an older version of CodeWarrior to write my code and it has problems with the new SDK. So I haven't downloaded the JavaMail API yet, it looks to me like this SMTPClient does everything I need. But I'm having problems sending HTML messages. I test my code by sending the messages to my own Outlook Express account. Outlook express interprets very simple HTML messages correctly, but as soon as I add more complicated tags it stops interpreting the message as HTML and just prints out the HTML source as plain text. This works fine:
msg.println("<html><body bgcolor=#D67689>");
msg.println("This works Fine!");
msg.println("</html>");
But I want to put together a slicker message than that. As soon as I add more code to the message, it is not interpreted properly.
This does not work:
msg.println("<html><body bgcolor=#D67689>");
msg.println("Now I just get plainText!");
msg.println("<img border=0 src=http://members.shaw.ca/bryantronsgard/IMAGES/FlowerBanner.jpg width=467 height=199>");
msg.println("</html>");
Do you have to follow some stricter tag schema when sending HTML over SMTP? Is there some trick I am missing?

I know nothing of this SMTPClient, but if it doesn't support setting a message's content type to "text/html" then it doesn't do everything you need.

Similar Messages

  • KNOWN ISSUE: HTML Messages with plain-text signatures

    To get around the EAS security policy issue, I'm having non-sensitive emails from work forwarded to a GMail account from a redirect set up in our corporate OWA. The redirect seems to send the messages to GMail without any issues; formatting is 100% intact, and in the GMail web client as well as Thunderbird, Entourage, etc., HTML emails with plain-text signature attachments show the plain-text message inline with the rest of the formatted message. All of our internal mailing lists have these plain text attachments that say where the message was coming from (Message sent from [email protected] by listserv). These get affixed to every message, both plain text and HTML.
    Here's my problem: The Pre's email client handles both plain text and HTML messages beautifully. But, when I receive a message from a mailing list with a plain text attachment, the HTML portion disappears, and all I see is the signature.
    Is there any way to make the Pre show the HTML INSTEAD of the plain text? I can live without the sig, I know where the messages are coming from already. But if I can't read the message, it's useless. I've only begun researching this and so far Google hasn't been much help, nor has searching these or other forums. Any help would be appreciated.
    Palm Pre P100EWW
    Post relates to: Pre p100eww (Sprint)
    Message Edited by HowellBP on 06-16-2009 04:13 PM

    1-51626418773
    I just got off the phone with Palm Support. Apparently this is a bug in the mail application. It currently does not support parsing both HTML and plain text in the same message. It will read EITHER plain text OR HTML, but not both at the same time. This will be fixed in a future update.

  • Trouble Forwarding HTML Messages with Entourage

    I use Entourage for email at home. Occasionally, I would like to be able to forward an email message to someone and keep the original HTML format intact. I have my preferences set to reply to messages in whatever format they were sent. For some reason, when I try to forward a message with lots of pictures in it, the forward messages just turns into text. Any suggestions?

    Oh wow! I thought it was me. Same issue here; Exchange 2007, and all I get is Plain Text. Yet I can go to another account, and write HTML mail, no problems...

  • Only code in recieved html messages

    hi,
    when i recieve html messages with mail, some display correct, others are just code. ex:
    --=_5b9a6928f167e76571ef059d7b1ca14d
    Content-Type: text/plain; charset="iso-8859-1"
    Content-Transfer-Encoding: 7bit
    test
    --=_5b9a6928f167e76571ef059d7b1ca14d
    Content-Type: text/html; charset="iso-8859-1"
    Content-Transfer-Encoding: quoted-printable
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.=
    w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns=3D"http://www.w3.=
    org/1999/xhtml" dir=3D"ltr" lang=3D"en"><html><head><meta http-equiv=3D"Con=
    there are a lot of threads regarding this problem with the email client "mail", but no solution.
    did apple released a patch yet?
    thanks

    maybe this helps more...
    Return-Path: <[email protected]>
    Delivered-To: [email protected]
    Received: (qmail 26064 invoked by uid 0); 5 May 2006 08:34:38 -0000
    Received: from unknown (HELO srv94-252.ip-tech.ch) (195.129.94.252)
    by blade1-7.iptech.localdomain with AES256-SHA encrypted SMTP; 5 May 2006 08:34:38
    -0000
    Received: (qmail 12980 invoked by uid 504); 5 May 2006 08:34:38 -0000
    Received: from unknown (HELO srv2-2.ip-tech.ch) (10.10.2.100)
    by 0 with SMTP; 5 May 2006 08:34:38 -0000
    Received: (qmail 14295 invoked by uid 65534); 5 May 2006 08:34:37 -0000
    Date: 5 May 2006 08:34:37 -0000
    Message-ID: <[email protected]>
    To: "martin knecht" <[email protected]>
    Subject: test
    X-PHP-Script: www.mikrokosmos-music.ch/shop/admin/mail.php for 62.202.75.246
    From: "mikrokosmos music" <[email protected]>
    MIME-Version: 1.0
    X-Mailer: Zen Cart Mailer
    Content-Type: multipart/alternative;
    boundary="=_59e34596dc5f8135e7c61b0bfb40f7d8"
    --=_59e34596dc5f8135e7c61b0bfb40f7d8
    Content-Type: text/plain; charset="iso-8859-1"
    Content-Transfer-Encoding: 7bit
    test
    --=_59e34596dc5f8135e7c61b0bfb40f7d8
    Content-Type: text/html; charset="iso-8859-1"
    Content-Transfer-Encoding: quoted-printable
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.=
    i think the header information is ok, entourage and thunderbird do display the message correct...
    thanks<br>

  • HTML Message

    I'd like to send a message (MS Outlook called it HTML message) with special effects such as bold, italic and the other font. How could I do this?
    Thanks,
    Charles

    Hi Bob,
    Thanks for your message. I sent out two new messages to myself. I wrote one sentence without bold or italic in a message and two sentences in the other in which the first one was no bold and italic (just typed one sentence) and the second was with bold and italic.
    The first resulting message was in plain text. Raw source indicated the second message contained plain text for the first sentence and html (formatted) text for the second sentence.
    In other words, html is in effect only if there is any format in the message. Even you pre-set rich text, you still have to do some format (such as bold).
    Do you get the same result?
    With my result, rich text message is not really a rich text message.
    Charles

  • HTML messages in mail.app ???

    Ok this may be a really obvious and idiotic question but.... I'm thinking of starting to use "mail.ap" instead or Entourage and I simply can't find something. I want to always use HTML messages and yet the only options I "appear" to have is under Preferences->Compose and I can only select "plain text" or "Rich text" as my message format. Does this mean I can't send HTML mesages? Is that really the case?
    If I can send HTML messages could someone please tell me how?
    TIA,
    Peter

    You can't compose html messages with Mail but it will view received html emails.

  • In Mail 3.6 remote images in HTML messages display as blue squares with ? even though checked in viewing references.

    In Mail 3.6 remote images in HTML messages display as blue squares with ? even though checked in viewing references.

    Nurit,
    The point is that that button should not be there, if the preference setting is as you say. This indicates the preference setting is stuck, and that is what I was trying to help you resolve.
    The full purge is done as follows:
    Quit Mail, and in the Finder open Home/Library and locate the Mail folder. Control-click over the Mail folder, and choose Duplicate -- then drag the resulting copy to the Desktop for temporary backup. Next, open Home/Library/Preferences and find the com.apple.mail.plist file and drag it to the desktop.
    Relaunch Mail, which will open as though new, and when prompted to import anything DECLINE. Instead, re-enter your account info, and Mail will re-discover the account folders for your accounts, and all should be well, after setting preferences as you desire.
    Ask any needed questions, and keep us posted.
    Ernie

  • 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.
    Thanks

    Hi,
    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

  • When I forward a message with pictures/formatting, it all turns to text. Where do I set an option to HTML instead of text?

    I can forward the message with the formatting when I use "the other browser" by choosing OPTIONS, then HTML. I don't see how to do this in Firefox and it all turns to plain text.

    I believe that if you turn off "Send As SMS: off in the settings, it should only attempt to send as an iMessage and should fail if iMessage is unavailable. It tries to send an iMessage a few times and then if unable, it will send as an SMS if you have that turned on.

  • Mail crashes on message with bad HTML. How to delete or fix ?

    Hello all,
    I've got a strange problem with Mail crashing when reading a particular message that appears to have some bad HTML. Here's the story:
    I received an email conatining HTML. Mail displays the message just fine, but when I try to navigate away from the message (to the next message for example), Mail crashes. Anything I do after reading the message causes Mail to crash. I can't delete the message or move it to another folder without a crash.
    The worst part is that everytime I restart Mail it defaults to displaying this message -- so now it is stuck in a loop !
    I have deleted the message from the mail server (through webmail) so it has not affected Mail on my other computers, but I need to figure out how to delete it locally from this one. I dug around in the ~\Library\Mail folder and I can see the files for this account, but I can't figure out how to delete this particular message without deleting ALL my other messages -- I've got older mail that I still want to keep.
    How can I manually delete this individual message, without removing everything else ?
    Is there another way to "reset" Mail so it doesn't default to this message every time ? Maybe then I could delete it from within Mail.
    Any help is greatly appreciated.
    I hope a future update to Mail will fix this HTML problem. The same pages crashes Safari too....
    Regards,
    JN
    G5 Dual 2GHz   Mac OS X (10.4.9)   MacBook

    Hello John.
    You can launch Mail holding the Shift key down until the main window appears to prevent it from selecting any mailboxes or loading any messages upon start up.
    And there are at least three ways to select a message and delete it without displaying its contents:
    (1) You can hide the preview pane by dragging the separator bar between the message list and the preview pane to the bottom of the window, or by just double-clicking within the separator bar, so that the preview pane disappears and only the message list is visible. To make the preview pane visible again, drag the separator bar up from the bottom of the window, or just double-click on the separator bar again.
    (2) If you select the message with the mouse, the message is displayed in the preview pane when the mouse button is released, not when it’s pressed. This allows you to drag the message to the Trash or to any other mailbox without Mail trying to display its contents.
    (3) Ctrl-clicking on a message causes a contextual menu to appear, from which you can usually (but not always, don’t ask me why) choose Delete or Move To, before the contents of the message are displayed in the preview pane.

  • TS3276 Hello all, I am getting the following message with some emails I receive:- HTML enabled email client required to read this email. I don't really understand this and don't know what to do to allow me to open the email. Any help? Thanks, Alex

    Hello all, I am getting the following message with some emails I receive:- HTML enabled email client required to read this email. I really don't understand this message, am non techy, would anyone know how I can open and read the email? Thanks very much for any help, Alex

    In Mail I suggest you try 'View->Message->Plain text alternative'.
    Why? In multipart/alternative messages, such as this, the text/plain version should precede the text/html version, but Toyota have swapped them around. By default mail clients display the second version, assuming it to be HTML.
    Very strange.

  • How to send digitally sign S/MIME messages with Powershell cmdlet Send-MailMessage?

    Hello,
    using AD Windows PKI I assigned a certificate EKU (1.3.6.1.5.5.7.3.4) to sign emails and get this with
    autoenrollment also to my CERT Store PS
    CERT:\CurrentUser\UserDS\ or the certificate could found via MMC / certificates in the store structur under "Active Directory User Object".
    Signed messages (red icon) to send as S/MIME message using Outlook 2010 is not a problem.
    Using PowerShell cmdlet Send-MailMessage to be sent company notification for a new passwordpolicy some days before pwd expired?! I use the cmdlet already successfully to filling HTML bodies with variables and send to individuals accounts.
    Reduced simplified PS code:
    $SMTPBodyHtmlTemplate = Get-Content "C:\PS\Template\HTMLBody.html" | Out-String
    Function SendEmailNotification # /* SEND E-MAIL Notification to User */#
    [string] $SMTPServer = "mail.domain.local"
    $CurrentUser = "$env:username"
    [string]$SMTPFrom = (Get-ADUser $CurrentUser -properties mail).mail
    [string[]] $SMTPTo = $($Obj.EmailAddress)
    [string]$SMTPSubject = "Notification!"
    [String]$SMTPBodyHtml = $SMTPBodyHtmlTemplate.Replace("UserDisplayname","$($UserDisplayname)")
    Send-MailMessage -From $SMTPFrom -To $SMTPTo -Subject $SMTPSubject -BodyAsHtml $SMTPBodyHtml -dno OnFailure -SmtpServer $SMTPServer -encoding ([System.Text.Encoding]::UTF8) -ErrorAction Continue
    How can I use the PSDrive own CERT and using PowerShell cmdlet Send-MailMessage
    to send a signed message, without development experience?
    Thanks in advance for cooperation.
    Manfred Schüler

    Hi,
    could create with an other colleague a DLL file (with this informations) for successfully sending sign messages from PS-Script. 
    Function SendEmailNotification # /* SEND SIGN E-MAIL */#
    $SMTPBodyHtmlTemplate = Get-Content "C:\PS\Template\HTML.html" | Out-String
    [System.Reflection.Assembly]::LoadFile("C:\PS\Assembly\Cpi.Net.SecureMail.dll") | Out-Null
    [string]$strSmtpServer = "smtp.domain.local"
    [string]$strSmtpPort = "25"
    [string]$strFrom = (Get-ADUser $CurrentUser -properties mail).mail
    [string]$strFromAlias = (Get-ADUser $CurrentUser -properties DisplayName).DisplayName
    [string]$strTo = $UserEmailAddress
    [string]$strToAlias = $UserEmailDisplayName
    [String]$strSubject = "Subject as you like"
    [string]$strBody = $SMTPBodyHtmlTemplate.Replace("UserDisplayname","$($UserDisplayname)")
    $objMail = New-Object Cpi.Net.SecureMail.SecureMailMessage
    $objFrom = New-Object Cpi.Net.SecureMail.SecureMailAddress($strFrom,$strFromAlias,$objCert,$objCert)
    $objTo = New-Object Cpi.Net.SecureMail.SecureMailAddress($strTo,$strToAlias)
    $objMail.From = $objFrom
    $objMail.to.Add($objTo)
    $objMail.Subject = $strSubject
    $objMail.Body = $strBody
    $objMail.IsBodyHtml = $TRUE
    $objMail.IsSigned = $TRUE
    $objMail.IsEncrypted = $FALSE
    $objSMTPClient = New-Object System.Net.Mail.SmtpClient($strSmtpServer,$strSmtpPort)
    $objSMTPClient.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
    $objSMTPClient.send($objMail)
    Maybe Microsoft can implement this in future versions of the cmdlets Send-MailMessage ;-)
    Manfred Schüler

  • Generate HTML report with ANT

    Hello,
    I'm  new to FlexPMD. I have just generated my firsts reports. I try to generate HTML reports.
    I browse the documentation, this forum and the web and I find informations to :
    - generate documentation with Hudson
    - generate documentation with Maven
    - generate documentation with XSLT pmd.xml -> html
    Ok, I try to keep it simple. So I don't want to use Hudson.
    I'm using ANT, and I currently don't want to install/learn Maven.
    I'm using FlexUnit with ANT. And It's really simple to generate reports :
    <junitreport todir="${report.flexunit.loc}">
                <fileset dir="${report.flexunit.loc}">
                    <include name="TEST-*.xml" />
                </fileset>
                <report format="frames" todir="${report.flexunit.loc}/html" />
    </junitreport>
    I'm really new to FlexPMD, so I don't have currently a big knowledge, but it seems impossible to generate a HTML report just like junitreport. (1 line in an ANT task)
    I test the XSLT transformation found on this forum (thread "XSLT pmd.xml -> html"). It's really cool. But it's seems difficult, for example, to extract the wrong code part and add it to the HTML page.
    So, what is the simpler solution to generate HTML report just with FlexPMD/ANT ?
    Thanks !

    Hello,
    Currently you generate a PMD report with ANT  like this :
    <! -- define taskdef  -->
    < taskdef name="pmd"  classname="com.adobe.ac.pmd.ant.FlexPmdAntTask"  classpath="${build.pmd.loc}/flex-pmd-ant-task-${flexpmd.version}.jar">
             < classpath>
                 < path refid="flexpmd.base" />
                 < pathelement  location="${build.pmd.loc}/commons-lang-2.4.jar" />
                 < pathelement  location="${build.pmd.loc}/flex-pmd-core-${flexpmd.version}.jar" />
                 < pathelement  location="${build.pmd.loc}/flex-pmd-ruleset-api-${flexpmd.version}.jar"  />
                 < pathelement  location="${build.pmd.loc}/flex-pmd-ruleset-${flexpmd.version}.jar"  />
                 < pathelement  location="${build.pmd.loc}/plexus-utils-1.0.2.jar" />
             < /classpath>
    < /taskdef>
    then generate XML  report like this :
    < pmd  sourceDirectory="${src.loc}" outputDirectory="${report.loc}"  ruleSet="${build.pmd.loc}/rules.xml"/>
    The  XML contains some file nodes :
    < file  name="/Users/user/workspace/AS3_UTILS/src/utils/align/gridAlignSpaceNumber.as">
           < violation beginline="22" endline="22" begincolumn="0"  endcolumn="27" rule="adobe.ac.pmd.rules.naming.TooShortVariable"  ruleset="All Flex Rules" package="utils.align"  class="gridAlignSpaceNumber.as" externalInfoUrl="" priority="5">This  variable name is too short (3 characters minimum, but 1 actually).  Detects when a field, local, or parameter has a very short name<  /violation>
    < /file>
    The  message is in the text node  < violation>TEXT< /violation>
    For  me, we miss an important part of the message : the portion of the "bad"  code.
    It could be very usefull if PMD can generate  something like this :
    < file  name="">
           < violation beginline="" endline="" begincolumn=""  endcolumn="" rule=""  ruleset="" package=""  class="gridAlignSpaceNumber.as" externalInfoUrl="" priority="">
            < description>TEXT< /description>
            < code><CDATA[MY CODE
    MY CODE
    MY CODE]>< /code>
        <  /violation>
    < /file>
    With this, we can  generate "full" HTML report with XSLT transform easily.
    I  understand that it modify the standard XML schema of the output.
    So,  perharps it could be an option like this :
    < pmd fullDescription="true"  sourceDirectory="${src.loc}"  outputDirectory="${report.loc}"  ruleSet="${build.pmd.loc}/rules.xml"/>
    What do you think ?
    Thanks !

  • HTML messages crash Mail

    Since this morning, every time I try to open an HTML message in Mail, it crashes. I don't have a problem with regular text e-mails, just HTML. I've repaired permissions, run Disk Utility and Disk Warrior, and I don't know how to proceed.
    Can anyone help, please?

    Hi lsgmilano, and a warm welcome to the forums if you han't been already!
    First I'd backup your whole Mail folder, by right clicking on it in the Finder, then choose Archive/Compress.
    Right click on that Mail folder, choose archive, you'll get everything in the folder, and the folder itself in a file called Mail.zip..
    Quit Mail, then In your home folder, try moving this +folder & file+ to the Desktop then reboot...
    /Users/YourUserName/Library/Caches/Mail
    Move to the Desktop...
    /Users/YourUserName/Library/Mail/Envelope Index

  • Is it possible to have Thunderbird send an e-mail automatically when a message with a specific subject is received?

    Is it possible to have Thunderbird send an e-mail automatically when a message with a specific subject is received?
    I basically want to create a rule that will send an automatically crafted form e-mail to the sender when I receive an e-mail with the subject line "New Swimmer". Is this possible?

    Thank you Todd, I was able to get it to work but I do have a few more questions...
    1) When I tested this, at the top of the message, before any of the text I created, this showed up: This is a multi-part message in MIME format. --------------040406040801080102080500 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
    2) After the signature line, this showed up: --------------040406040801080102080500 Content-Type: image/jpeg Content-Transfer-Encoding: base64 Content-ID: /9j/4AAQSkZJRgABAQEAYABgAAD/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAEAAAAA AAD/2wBDAAIBAQIBAQICAgICAgICAwUDAwMDAwYEBAMFBwYHBwcGBwcICQsJCAgKCAcHCg0K CgsMDAwMBwkODw0MDgsMDAz/2wBDAQICAgMDAwYDAwYMCAcIDAwMDAwMDAwMDAwMDAwMDAwM DAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAz/wAARCAC5ApUDASIAAhEBAxEB/8QA HwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQID AAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6 Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm p6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/
    (It was actually much longer than that)
    Is there anyway that I can get that to go away? I obviously would prefer a nice, cleanly formatted e-mail to be sent just like I would send if I were creating it on the spot.
    Thanks,
    Evan

Maybe you are looking for