HtmlText Text
Hi guys,
Does somebody have an idea to convert htmlText to text, it
means remove the Angle Brackets.
Example:
<FONT ...>Lorem Ipsum</FONT>
to
Lorem Ipsum
I don't know, RegExp, some String Method ? :S
Thanks,
Core
Nevermind, i resolved it.
Create a RichTextEditor pass the "htmlText" to it, then
accessing to is "Text"
proproety it's
tag free :D
Example:
<mx:RichTextEditor x="20" y="10" title="Title"
id="richText">
<mx:htmlText>
<![CDATA[
<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT
FACE="Verdana" SIZE="10" COLOR="#0B333C" LETTERSPACING="0"
KERNING="0">Ola
tudo bem?</FONT></P></TEXTFORMAT>
]]>
</mx:htmlText>
</mx:RichTextEditor>
<mx:TextArea x="491" y="10" width="260" height="300"
backgroundColor="#0E0E0E" color="#FFFFFF"
text="{richText.text}"/>
The text in the TextArea are not formated was i wanted :)
Thanks, anyway
Similar Messages
-
Hi,
I have some dynamic text within a scrolbar controlled box. I
need to link certain words of the text but, whenever I attempt to
do this, the entire text block becomes 'linked'. Does anyone know
how I can solve this?
Many thanks.Then you'll need to use html links for the words. So when you
assign the text to the textfield, you'll need to assign it as...
tField.htmlText = "text.... <a href='...>link
text</a>"... text;
where tField is whatever instance name you assigned to the
textfield -
I have an 800 page pdf document to index and so far I have a script that will search for a list of keywords. But the text has large sections of code in a different font, and I think we would like to generate an index of just code examples. Is there a way to search for text of a given font in applescript? Something like
set theSel to find text theText
if the font of theSel is "Times"
write to file, etc.Please do send a page, I might be able to spot where the font problem is coming from - but no guarantee Address is in my profile.
You asked about the script formatter. red_menace of this forum wrote the script I use. To use it, you copy the script that you want to format to the clipboard and run the formatter. This then places the marked-up text in the clipboard so that you can paste it into the forum page.
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 340px;
color: #000000;
background-color: #FFDDFF;
overflow: auto;">
script formatter - formats the clipboard text for forum posting
last reviewed January 19, 2009 red_menace[at]mac[dot]com
Input: text read from the clipboard
Output: formatted text copied to the clipboard
set AppleScript's text item delimiters to " "
-- some constants and switches
property TextColor : "#000000" -- black (see http://www.w3schools.com/tags/ref_colornames.asp)
property BackgroundColor : "#FFDDFF" -- a light plum/purple
property BorderColor : "#000000" -- black
property TheWidth : "width: 720px; " -- a width attribute (deprecated in HTML 4.01)
property UseWidth : true -- use the width attribute?
property LineCount : 25 -- the number of lines before including the height attribute
property TheHeight : "height: " & ((LineCount * 13.6) as integer) & "px; " -- a maximum height for the <pre> box
property Emphasize : false -- emphasise (bold) the script text?
property UseURL : false -- include a Script Editor message link?
property AltURL : false -- use an alternate URL encoding?
property ToolTips : {¬
"this text can be pasted into the Script Editor", ¬
"this text can be pasted into an Automator 'Run AppleScript' action", ¬
"this text can be pasted into an Automator 'Run Shell Script' action", ¬
"this text can be pasted into a HTML editor", ¬
"this text can be pasted into a text editor", ¬
"- none -"}
property TooltipDefault : {item 1 of ToolTips} -- keep track of the last tooltip used
property TempFile : "Script_Formatter_TempFile" -- a temporary work file
try
-- write the clipboard to the temporary file
set TheClipboard to (the clipboard) as text
if TheClipboard is in {"", space, tab, return} then return -- clipboard is (basically) empty
set MyOpenFile to open for access ("/tmp/" & TempFile & ".txt" as POSIX file) with write permission
set eof of MyOpenFile to 0 -- empty any previous temp file
write TheClipboard to MyOpenFile
close access MyOpenFile
if UseURL then
-- encode URL (see http://developer.apple.com/documentation/Darwin/Reference/Manpages/man1/pydoc.1. html)
do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of TheClipboard
-- add a link wrapper
set URLtext to "applescript://com.apple.scripteditor?action=new&script=" & the result
if AltURL then -- use an alternate URL encoding
set URLtext to "Click here to [url=" & URLtext & "]open this script in the Script Editor[/url]:<br />"
else -- use HTML anchor tag
set URLtext to "Click here to <a href=\"" & URLtext & "\">open this script in the Script Editor</a>:<br />"
end if
set PromptText to ((count URLtext) as text) & " URL and "
else
set {URLtext, PromptText} to {"", ""}
end if -- UseURL
-- convert to HTML (see http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/textutil .1.html)
do shell script "cd /tmp/; /usr/bin/textutil -convert html -excludedelements '(html, head, title, body, p, span, font)' -encoding US-ASCII " & TempFile & ".txt"
-- fix up some formatting and add a pre wrapper (see http://www.w3schools.com/tags/default.asp)
set HTMLtext to rest of paragraphs of (read ("/tmp/" & TempFile & ".html" as POSIX file))
if (count HTMLtext) is less than LineCount then -- skip the height attribute
set Height to ""
else
set Height to TheHeight
end if
set HTMLtext to FixCharacters from (HTMLtext as text) -- additional character encodings
if UseWidth then
set Width to TheWidth
else
set Width to ""
end if
if Emphasize then set HTMLtext to "<strong>" & HTMLtext & "</strong>"
set HTMLtext to "<pre style=\"
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid " & BorderColor & ";
" & Width & Height & "
color: " & TextColor & ";
background-color: " & BackgroundColor & ";
overflow: auto;\"
title=\"\">
" & HTMLtext & "</pre>
-- assemble everything on the clipboard
set TheResult to choose from list ToolTips ¬
with title "Script Formatted" with prompt PromptText & ((count HTMLtext) as text) & " HTML characters will be placed on the clipboard (plus the following ToolTip):" default items TooltipDefault OK button name "OK" cancel button name "Cancel" with empty selection allowed without multiple selections allowed
if TheResult is false then -- cancel button
error number -128
else -- add the selected title attribute (tooltip), if any
set TooltipDefault to TheResult as text
set Here to (offset of " title=" in HTMLtext) - 1
set There to (offset of ">" in HTMLtext) - 1
if TheResult is in {{}, "- none -"} then -- no tooltip
set the clipboard to URLtext & (text 1 thru (Here - 1) of HTMLtext) & (text (There + 1) thru -1 of HTMLtext)
else
set the clipboard to URLtext & (text 1 thru (Here + 9) of HTMLtext) & TheResult & (text There thru -1 of HTMLtext)
end if
end if -- TheResult is false
on error ErrorMessage number ErrorNumber
log space & (ErrorNumber as text) & ":" & tab & ErrorMessage
try
close access MyOpenFile
end try
if (ErrorNumber is -128) or (ErrorNumber is -1711) then -- nothing (user cancelled)
else
activate me
display alert "Error " & (ErrorNumber as text) message ErrorMessage as warning buttons {"OK"} default button "OK"
end if
end try
to FixCharacters from TheText
fixes (converts) formatting characters used in some message forums (see http://www.asciitable.com/)
parameters - TheText [text]: the text to fix
returns [text]: the fixed text
-- this list of lists contains the characters to encode - item 1 is the character, item 2 is the HTML encoding
set TheCharacters to {¬
{"!", "!"}, ¬
{"*", "*"}, ¬
{"+", "+"}, ¬
{"-", "-"}, ¬
{"[", "["}, ¬
{"\\", "\"}, ¬
{"]", "]"}, ¬
{"^", "^"}, ¬
{"_", "_"}, ¬
{"~", "~"}}
set TempTID to AppleScript's text item delimiters
repeat with SomeCharacter in TheCharacters
if item 1 of SomeCharacter is in TheText then -- replace
set AppleScript's text item delimiters to item 1 of SomeCharacter
set the ItemList to text items of TheText
set AppleScript's text item delimiters to item 2 of SomeCharacter
set TheText to the ItemList as text
end if
end repeat
set AppleScript's text item delimiters to TempTID
return TheText
end FixCharacters
</pre> -
Text Align ignores whitespaces
Hi.
I have a problem with text align in text field.
Let's say that I have a text field with htmlText:
"Text example "
- when I set align for this text field like this:
var _format:TextFormat = new TextFormat();
_format.align= TextFormatAlign.CENTER;
text_field.setTextFormat(_format);
- it ignores whitespaces at the end of the line.
Same thing for TextFormatAlign.RIGHT.
Can I change this behavior using new text layout framework?I don't think you can. TLF ignores trailing spaces when aligning text as well. And the decisions for where a glyph appears on a line are in the Player - not our actionscript code - so there isn't a way to override this in TLF.
-
Using multiple img src / with htmlText --display problem
I need help.
I am using multiple <img src /> tag with htmlText and
pictures displays in layers(overlay)?
html_txt.html = true;
html_txt.htmlText = "text<br><img src = '
http://picture1.jpg 'width='500'
height='491' hspace='0' /><br>more text<br><img
src = '
http://picture2.jpg' width='299'
height='612' hspace='101' ><br>end with text";
Is there any way to refresh text field when pictures are
fully loaded so it will display like regular html page?
this is flash version, evrything is shown but it is not
right.
http://www.sosui.jp/flash/test/v001/pages/home/homeBlogV002.swf
I want to show them like this page.
http://sosui.jp/flash/test/v001/pages/home/blog.html
I tried onEnterFrame but pictures will not show. I think it
is because it is trying to load pictures everytime. So I cannot use
onEnterFrame, i need other way to refresh text field.
Please help me. you might of guessed I am not an English
speaker, so my English might be little off.
Thank you.does anybody know anything? how long do i need to wait to see
if someone replies? I just need to know if it is possible or not. -
How to Improve Design for HTML, Plain Text and Multiple Recipients?
Hello there,
JavaMail programming is so fun! I first start off mixing the JavaMail code inside a servlet and then refactored it to two separate classes.
Mailer is the independent class which uses JNDI to look up config parameters, sends e-mails, and then closes the connection with the protocol.
public class Mailer {
private Session mailSession;
protected void sendMsg(String email, String subject, String body)
throws MessagingException, NamingException {
Properties props = new Properties();
InitialContext ictx = new InitialContext(props);
Session mailSession = (Session) ictx.lookup("java:/Mail");
String username = (String) props.get("mail.smtps.user");
String password = (String) props.get("mail.smtps.password");
MimeMessage message = new MimeMessage(mailSession);
message.setSubject(subject);
message.setRecipients(javax.mail.Message.RecipientType.TO,
javax.mail.internet.InternetAddress.parse(email, false));
message.setText(body);
message.saveChanges();
Transport transport = mailSession.getTransport("smtps");
try {
transport.connect(username, password);
transport.sendMessage(message, message.getAllRecipients());
Logger.getLogger(this.getClass()).warn("Message sent");
finally {
transport.close();
}MailController is just a simple Java servlet where a Mailer object is instantiated and a String is passed inside the Mailer.sendMsg() method.
public class MailController extends HttpServlet {
/** static final HTML setting for content type */
private static final String HTML = "text/html";
myapp/** static final HTML setting for content type */
private static final String PLAIN = "text/plain";
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType(PLAIN);
PrintWriter out = response.getWriter();
String mailToken = TokenUtil.getEncryptedKey();
String body = "Hello there, " + "\n\n"
+ "Wanna play a game of golf?" + "\n\n"
+ "Please confirm: https://localhost:8443/myapp/confirm?token="
+ mailToken + "\n\n" + "-Golf USA";
Mailer mailer = new Mailer();
try {
mailer.sendMsg("[email protected]", "Golf Invitation!", body);
out.println("Message Sent");
catch (MessagingException e) {
e.printStackTrace();
catch (NamingException e) {
e.printStackTrace();
}Have some design issues...
If you can notice, I manually place the body of the e-mail (as a String) from inside the client (in this case, a Java Servlet). Also, I manually have to switch the content type inside the doPost().
Question(s):
(1) How can the Mailer class be set up, so it can send both HTML and plain text messages?
(2) How can the Mailer class be structured to send e-mail to multiple recipients or one user?
(3) Would both of these features / actions require writing two overloaded methods for sendMsg()?
Would appreciate it if someone could help me...
Happy programming,
MichaelOkay, I came up with this single method:
Mailer.java:
public class Mailer
private Session mailSession;
protected void sendMessage(String email, String recipient, String subject,
String plainText, String htmlText)
throws MessagingException, NamingException
Properties props = new Properties();
InitialContext ictx = new InitialContext(props);
Session mailSession = (Session) ictx.lookup("java:/Mail");
String username = (String) props.get("mail.smtps.user");
String password = (String) props.get("mail.smtps.password");
MimeMessage message = new MimeMessage(mailSession);
InternetAddress from = new InternetAddress(email);
InternetAddress to = new InternetAddress(recipient);
message.setSubject(subject);
message.setFrom(from);
message.addRecipient(Message.RecipientType.TO, to);
Multipart multipart = new MimeMultipart();
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(plainText);
multipart.addBodyPart(messageBodyPart);
messageBodyPart = new MimeBodyPart();
messageBodyPart.setContent(htmlText, "text/html");
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
Transport transport = mailSession.getTransport("smtps");
try {
transport.connect(username, password);
transport.sendMessage(message, message.getAllRecipients());
Logger.getLogger(this.getClass()).info("Message sent");
catch (Throwable t) {
Logger.getLogger(this.getClass()).error("Unable to Send Message");
t.printStackTrace();
finally {
transport.close();
}Created a MailController class to instantiate and run the Mailer class.
public class MailController extends HttpServlet {
// doPost() method()
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType(PLAIN);
PrintWriter out = response.getWriter();
String mailToken = TokenUtil.getEncryptedKey();
String plainText = "Hello there, " + "\n\n"
+ "I wanna invite you to a game of golf!" + "\n\n"
+ "Please confirm: https://localhost:8443/myapp/confirm?token="
+ mailToken + "\n\n" + "-Golf USA";
String htmlText = "<H1>Golfer Challenge!</H1>";
Mailer mailer = new Mailer();
try {
String from = "[email protected]";
String recipient = "[email protected]";
String subject = "Golf Challenge";
mailer.sendMessage(from, recipient, subject, plainText, htmlText);
Logger.getLogger(
this.getClass()).info("Message Sent to: " + recipient
+ " from: " + email);
out.println("Message Sent to: " +
recipient + "\n" + " from: " + email);
catch (MessagingException e) {
e.printStackTrace();
catch (NamingException e) {
e.printStackTrace();
}Question(s):
(1) How come the Multipart Alternative only supports HTML for the second part? Can I specify it to send HTML first and plainText second?
(2) How would I send in multiple recipients? Would I have to pass in an array reference (surrounded by a for loop) inside sendMessage() as follows:
mailer.sendMessage(from, myArray, subject, plainText, htmlText);
Thank you for all of your help!
-Michael -
Hi,
I need to pass htmlText to a server-side script via a
URLRequest, but I get this error because the html has single quotes
in it and is being sent via POST as a variable. How can I encode
the htmlText so it passes " \' " for each " ' "? I assume that will
solve the issue.
Error: Error #2101: The String passed to
URLVariables.decode() must be a URL-encoded query string containing
name/value pairs.
Thanks!I have the same problem (more or less, I have problems
sending & ) sending some html text to a php script and to solve
it I used RegExp:
var loader:URLLoader=new URLLoader;
var req:URLRequest=new URLRequest($php+'addmail.php');
var vars:URLVariables=new URLVariables;
var myp:RegExp = /&/g;
req.method='POST';
req.data=vars;
vars.oggetto=oggetto.text;
vars.argomento=argomento.text;
vars.data=data.text;
vars.allegato=allegato.text;
vars.corpohtml=htmltext.htmlText.replace(myp,'\&');
vars.corpotxt=htmltext.text.replace(myp,'\&');
loader.load(req);
loader.addEventListener(Event.COMPLETE,getRes);
function getRes():void {
var vrs:URLVariables=new URLVariables(loader.data);
if (vrs.result==1) {
Alert.show('Il mail e stato salvato','Confirm');
} else {
Alert.show('Il mail non puo essere salvato, riprovare piu
tardi!','Error');
} -
Having problems with autosizing height on a text control. I'm
setting the text dynamically and when I set it the first time, it
doesn't adjust the height properly to display text multiline if
needed, it just get cut off. If I set the text one more time
though, it seems to adjust fine. Problem is that first time, seems
the height isn't being set properly. Here's what I've got.
private function switchTitle(text:String):void {
title.htmlText = text;
<mx:Text id="title" width="340" styleName="featuredTitle"
textAlign="left" paddingTop="1" />I have been loooking at this and I see your point. I will have to replace the text box with a movieclip to see if it works.
thx
rd -
Problem in converting some images
Hi all,
I have a problem when converting a word document in pdf (using acrobat 9). If i use the standard settinings, everything works fine. If I use personalised options to mantain bookmarks and links in the final pdf, some images (png) after the conversion appear with some black stripes on top of them.
Does someone encountered the same problem?
Thank You!Sorry for the delay in my response. I was on vacation.
I tried following code (giving the type as related). But still it didn't work out :(
I am sure i am doing some silly mistake. I guess mistake is in how i use cid:imageDo i need to use four unique cid tag if i attach four images? If yes can someone help me how? Thanks
MimeMultipart multiPart = new MimeMultipart("related");
MimeBodyPart msgBody = new MimeBodyPart();
String htmlText = content+"<H1></H1><img src=\"cid:image\">";
msgBody.setContent(htmlText, "text/html");
multiPart.addBodyPart(msgBody);
File folder = new File("./result");
File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++)
MimeBodyPart attachmentPart = new MimeBodyPart();
FileDataSource fds = new FileDataSource(listOfFiles.getAbsolutePath());
attachmentPart.setDataHandler(new DataHandler(fds));
attachmentPart.setFileName(listOfFiles[i].getName());
attachmentPart.setHeader("Content-Type", "image/png" );
//attachmentPart.setDisposition("inline");
attachmentPart.setHeader("Content-ID","image"+i);
mp.addBodyPart(attachmentPart);
System.out.println("Attached the file " + listOfFiles[i].getAbsolutePath());
mess.setContent(multiPart); -
How to change font type in java mail script?
Hi,
I wrote a bean shell script to send mail on particular event. I want mail message body text font style to be modified.
Please provide help on this.
Thanks,
SaloniHi Saloni ,
You can add the text in the following way by using font tags for message body in your custom mail.
Message msg = new MimeMessage(session);
MimeMultipart mp = new MimeMultipart();
MimeBodyPart mbp1= new MimeBodyPart();
String htmlText = "<b> This is formatted</b>"+
"<font size =\"5\" face=\"arial\" >This paragraph is in Arial, size 5</font>";
mbp1.setContent(htmlText,"text/html");
mp.addBodyPart(mbp1);
msg.setContent(mp);
It worked for me. Let me know if you face any issue.
Regards,
Uday. -
when i push the button to send a mail in my Web dnypro application
there is an warning occured like this:
Sending failed; nested exception is: javax.mail.MessagingException: 454 5.7.3 Client does not have permission to submit mail to this server.
what's the matter?(is that interrelated with the sending mail host)Make sure you maintain java mail client settings in Visual Admin
use the following code example to send mail messages
Properties props = new Properties();
props.put("domain", "true");
Context initialContext = new InitialContext(props);
Session sess = (Session) initialContext.lookup("java:comp/env/mail/MailSession");
Session mailSession = Session.getDefaultInstance(sess.getProperties());
Transport transport = mailSession.getTransport("smtp");
//MimeMessage message = new MimeMessage(sess);
MimeMessage message = new MimeMessage(mailSession);
message.setSubject("Your ERP Portal Certificate");
message.setFrom(new InternetAddress("[email protected]"));
message.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(userArr.getEmail()));
// This HTML mail have to 2 part, the BODY and the embedded image
MimeMultipart multipart = new MimeMultipart("related");
// first part (the html)
BodyPart messageBodyPart = new MimeBodyPart();
String htmlText ="Dear ERP user , </b>" ; messageBodyPart.setContent(htmlText, "text/html");
// add it
multipart.addBodyPart(messageBodyPart);
// put everything together
message.setContent(multipart);
transport.connect();
transport.sendMessage(message, message.getRecipients(javax.mail.Message.RecipientType.TO));
transport.close();
proxy.gotoPage("umHelpPage");
uidUserCreatteLog(userArr.getEmail());
chk it also
Re: Sending Email from Web Dynpro -
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?
-
Problem in embedding Multiple Images
Dear members,
I am composing a mail in java mail. In the body i am trying to embed (Note: Not attach) three images files. But, only the first image is getting embedded. Other 2 images are only getting attached, not coming as embedded images.I tried various options like changing Mime subtype, setting disposition as inline, etc... But nothing worked. I am pasting the code here. Any help is high appreciated.
MimeMultipart multiPart = new MimeMultipart("alternative");
File folder = new File("./result");
File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++)
System.out.println("Attaching file " + listOfFiles.getAbsolutePath());
MimeBodyPart msgBody = new MimeBodyPart();
String htmlText = "<img src=\"cid:image"+i+"\">";
msgBody.setContent(htmlText, "text/html");
mp.addBodyPart(msgBody);
MimeBodyPart attachmentPart = new MimeBodyPart();
FileDataSource fds = new FileDataSource(listOfFiles[i].getAbsolutePath());
attachmentPart.setDataHandler(new DataHandler(fds));
attachmentPart.setFileName(listOfFiles[i].getName());
attachmentPart.setHeader("Content-Type", "image/png" );
attachmentPart.setHeader("Content-ID","image"+i);
mp.addBodyPart(attachmentPart);
ThanksSorry for the delay in my response. I was on vacation.
I tried following code (giving the type as related). But still it didn't work out :(
I am sure i am doing some silly mistake. I guess mistake is in how i use cid:imageDo i need to use four unique cid tag if i attach four images? If yes can someone help me how? Thanks
MimeMultipart multiPart = new MimeMultipart("related");
MimeBodyPart msgBody = new MimeBodyPart();
String htmlText = content+"<H1></H1><img src=\"cid:image\">";
msgBody.setContent(htmlText, "text/html");
multiPart.addBodyPart(msgBody);
File folder = new File("./result");
File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++)
MimeBodyPart attachmentPart = new MimeBodyPart();
FileDataSource fds = new FileDataSource(listOfFiles.getAbsolutePath());
attachmentPart.setDataHandler(new DataHandler(fds));
attachmentPart.setFileName(listOfFiles[i].getName());
attachmentPart.setHeader("Content-Type", "image/png" );
//attachmentPart.setDisposition("inline");
attachmentPart.setHeader("Content-ID","image"+i);
mp.addBodyPart(attachmentPart);
System.out.println("Attached the file " + listOfFiles[i].getAbsolutePath());
mess.setContent(multiPart); -
Sending HTML + related images + attachments
Hello,
I want to send an HTML file + related images + attachments.
I actually succeeds in sending HTML content + related images.
I also know how to attach files in a mail.
But when I want to have both of those functionnalities in the same mail, I miserably fail... ;)
Does anyone have a simple example that sends an HTML file + related images + attachments??
HELP!!!!
Denis.USe this as a **guide**.
Its sends images + altText(similar to attachment, except that its embedded + html)
public static void sendC()throws Exception{
String host = "xx";
String from = "xxx";
String to = "xxx";
String file = "logo.gif";
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
Session session = Session.getDefaultInstance(props, null);
Message message = new MimeMessage(session);
message.setSubject("Embedded Image");
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
MimeMultipart multipart1 =new MimeMultipart("related");
//multipart1.setSubType("alternative");
MimeMultipart multipartBody = new MimeMultipart("alternative");
MimeBodyPart part=new MimeBodyPart();
part.setContent("textMessage","text/plain");
multipartBody.addBodyPart(part);
part=new MimeBodyPart();
String htmlText = "<H1>Hello</H1>" +"<img src=\"cid:memememe\">";
part.setContent(htmlText,"text/html");
multipartBody.addBodyPart(part);
MimeBodyPart mbpBody = new MimeBodyPart();
mbpBody.setContent(multipartBody);
multipart1.addBodyPart(mbpBody);
MimeBodyPart imagePart = new MimeBodyPart();
DataSource fds = new FileDataSource(file);
imagePart.setDataHandler(new DataHandler(fds));
imagePart.setHeader("Content-ID","<"+"memememe"+">");
imagePart.setDisposition("inline");
multipart1.addBodyPart(imagePart);
message.setContent(multipart1);
Transport.send(message);
You will have to make modifications so that the attchmetns are not embedded. -
I've been following the lynda.com AIR for Flash Devs
tutorial. It shows how to add the Scrollbar Class to an HTMLLoader.
Is it just me, or is Adobe's Scrollbar a rather odd
implementation?
I mean it works, but, for instance, the scroll handle you
grab with your mouse is always much much smaller than it should be
when compared to the actual content.
Also, I have the stage resizing and the scrollbars moving
properly, but I've noticed that resizing the app smaller, always
forces the scrollbar to appear, regardless of the content being
larger than the content area or not.
Is everyone using this implementation for scrolling, or are
people using something else?OK - my problem with the HTML Control is I can't seem to add it to a child custom class.
i.e. - I have my main Air app and a custom class extending UIComponent. I add the custom class to the stage in the main app, and in the custom class, add an HTML Control. I'm also adding a different HTML Control to the main app.
Only the HTML in the main app actually shows up. No errors given. What am I missing here?
Main Air app mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.controls.HTML;
var _myComp:Comp;
private function init():void {
_myComp = new Comp();
_myComp.init();
_myComp.x = 200;
_myComp.y = 200;
addChild(_myComp)
var html:HTML = new HTML();
html.htmlText = "Text on main application window"
addChild(html);
]]>
</mx:Script>
</mx:WindowedApplication>
Comp Class:
package {
import flash.display.Shape;
import mx.controls.HTML;
import mx.core.UIComponent;
public class Comp extends UIComponent {
public function Comp() {
public function init():void {
var shape:Shape = new Shape()
shape.graphics.beginFill(0,1)
shape.graphics.drawRect(0,0,200,400);
shape.graphics.endFill();
addChild(shape)
var html:HTML = new HTML();
html.htmlText = "Text Inside child component";
html.x = 200
this.addChild(html);
trace(html.htmlText)
Maybe you are looking for
-
OIM 9.1.0.2 Download??
Hi All, Anyone know if 9.1.0.2 is available for download anywhere? Everywhere I look on Oracle's site I end up here: http://www.oracle.com/technology/software/products/ias/htdocs/101401.html which only has 9.1.0.1. I need the ...0.2 version as it's t
-
Cannot display certain french glyphs running in Chinese NT 4.0
I have got a java application which supports english, french, german, spanish, italian languages. I have translations properties files which is loaded for the language the application is installed in(ResourceBundle, et al). I have a new requirement t
-
Hi, Can anybody tell the name of the report where Attendance hours per day for each employee for the course scheduled can be seen?
-
In the first frame of that movieclip, I'm importing an external swf with Loader class,(Using actionscript2 but my main flash page using Actionscript3), It is loading well but when i pass to second frame and return to the first frame again, the Loader
-
Cannot select object sent to back
If I make a rectangular, fixed object, select it, and choose Send Backward or Send to Back, I can no longer select it. Is there something I'm not understanding about how to re-select that object? -Michael