doesnt show the html format in outlook. please do reply me. sorry for the english
private void sendEmail() {
try {
String value = "<table>" +
"<tr>" +
"<td><b>Name </b></td>" +
"<td>android</td>" +
"</tr><br>" +
"<tr>" +
"<td><b>Version</b></td>" +
"<td>2.2</td>" +
"</tr>" +
"</table>";
Intent email_intent = new Intent(Intent.ACTION_SEND);
email_intent.setType("text/html");
email_intent.putExtra(Intent.EXTRA_SUBJECT, "android Details");
email_intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(value));
email_intent.setType("vnd.android.cursor.dir/email");
startActivity(Intent.createChooser(email_intent,"Sending mail.."));
}catch(Exception e) {
}
}
You have two setType() calls. Eliminate the second. Leave the email_intent.setType("text/html") there. See if that helps.
The <table>tag is apparently not supported by android jet See this link.
I'm also trying to show a table in an E-mail but I haven't succeeded jet.
Related
Sorry for the longer post, I'm trying to be specific. I'm a bit of a newb at cold fusion and lucee, so forgive me if I have missed something fundamental here. I'm just trying to do a quick POC, but can't get it working. What I am trying to do is make a page call, write to a web page, sleep for a while. Kind of a heartbeat. What I can't get to happen is the write to the web page...until all sleep(s) have happened and the page cfm file completes processing. I've looked extensively for the past couple of days, and have tried numerous items, but to no avail. From my index.cfm lucee page, I have a link to launch a new tab and call my cfm file.
<a href="./pinger2.cfm" target="_blank"><img class="ploverride" src="/assets/img/Ping.png" alt="Ping Test" width="125" height="75">
No problem here, a new tab opens and pinger2.cfm starts processing.
What I'm hoping for is the table heading to almost immediately print to the page, then make the first call out, print the results to the page, sleep, make the next call out, print to the page...but it no workey. Anyone have a clue? The code in the pinger2.cfm file is:
<cfscript>
public struct function pinger( required string url, required string verb, required numeric timeout, struct body )
{
var result = {
success = false,
errorMessage = ""
};
var httpService = new http();
httpService.setMethod( arguments.verb );
httpService.setUrl( arguments.url );
httpService.setTimeout( arguments.timeout );
if( arguments.verb == "post" || arguments.verb == "put" )
{
httpService.addParam(type="body", value=SerializeJSON(arguments.body));
}
try {
callStart = getTickCount();
var resultObject = httpService.send().getPrefix();
callEnd = getTickCount();
callLength = (callEnd-callStart)/1000;
if( isDefined("resultObject.status_code") && resultObject.status_code == 200 )
{
result.success = true;
logMessage = "Pinger took " & toString( callLength ) & " seconds.";
outLine = "<tr><td>" & resultObject.charset & "</td><td>" & resultObject.http_version & "</td><td>" & resultObject.mimetype & "</td><td>" & resultObject.status_code & "</td><td>" & resultObject.status_text & "</td><td>" & resultObject.statuscode & "</td><td>" & logMessage & "</td></tr>";
writeOutput( outLine );
getPageContext().getOut().flush();
return result;
}
else
{
throw("Status Code returned " & resultObject.status_code);
}
}
catch(Any e) {
// something went wrong with the request
writeDump( e );
abort;
}
}
outLine = "<table><tr><th>charset</th> <th>http_version</th> <th>mimetype</th> <th>status_code</th> <th>status_text</th> <th>statuscode</th> <th>time</th> </tr>";
writeOutput( outLine );
getPageContext().getOut().flush();
intCounter = 0;
while(intCounter LT 2)
{
theResponse = pinger(
url = "https://www.google.com",
verb = "GET",
timeout = 5
);
intCounter = intCounter + 1;
getPageContext().getOut().flush();
sleep(2000);
}
outLine = "</table>";
writeOutput( outLine );
</cfscript>
NOTE: I'm sure there are other "less than best" practices in there, but I'm just trying to do this quick and dirty.
I thought the getPageContext().getOut().flush(); would do the trick, but no bueno.
EDIT: If it matters, I'm using CF version 10,0,0,0 and Lucee version 4.5.2.018.
I do something similar to generate ETags by hand (using Lucee 4.5). I stick a simple
GetPageContext().getOut().getString()
in the onRequestEnd function in Application.cfc. This returns a string of HTML just like it's sent to the browser.
You could store that in the appropriate scope (APPLICATION, SESSION, etc) and use it later, or whatever you need. Obviously, all processing needs to be completed, but it shouldn't require any flushes. In fact, flushing may or may not alter its behavior.
I am working on some Java Servlets, and basically i am outputting the results of an sql query to a table. I have some basic formatting for the table in the html code, but i also want to link a css file.
Whenever i link a stylesheet (even a blank one, or one with the same attributes as the html tags in the table), it just destroys any formatting in the table, and outputs the results as one continuous list.
Any suggestions at all would be a great help.
Here's my servlet code:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String category = request.getParameter("categoryname");
AlbumDAO albumData = new AlbumDAO();
ArrayList<AlbumBean> albums = albumData.findFromCategory(category);
PrintWriter out = response.getWriter();
response.setContentType("text/html");
String title = category + " albums";
String stylesheet = "<link rel=\"stylesheet\" type=\"text/css\" href=\"/CSS/stylesheet.css>";
out.println("<!DOCTYPE html><html>");
out.println("<head>");
out.println("<title>" + title + "</title>");
out.println(stylesheet);
out.println("</head>");
out.println("<body>");
out.println("<Center><H1>" + category + " albums</Center>");
out.println("<table border=\"1\" cellspacing=\"5\" cellpadding=\"5\">"
+ "<tr><th>ID</th><th>Artist</th><th>Title</th><th>Image Name</th><th>Tracks</th><th>Price</th><th>In Stock</th></tr>");
for (AlbumBean a : albums){
out.println("<tr><td> "+ a.getRecording_id() + "</td>");
out.println("<td>" + a.getArtist_name() + "</td>");
out.println("<td> " + a.getTitle() + "</td>");
out.println("<td> " + a.getCategory() + "</td>");
out.println("<td> " + a.getImage_name() + "</td>");
out.println("<td> " + a.getPrice() + "</td>");
out.println("<td> " + a.getStock_count() + "</td>");
out.println("</tr>");
}
out.println("</table>");
out.println("</body>");
out.println("<footer> let's go home</footer>");
out.println("</html>");
}
Looks like you are not closing the quotation marks in your link statement
String stylesheet = "<link rel=\"stylesheet\" type=\"text/css\" href=\"/CSS/stylesheet.css\">";
I eventually solved it, the only thing was that i was thinking the folder CSS needed to be referenced as "/CSS/stylesheet.css"
whereas it was actually just "CSS/stylesheet.css" .
Thanks guys.
I am struggling to understand how I can achieve the look I want with HTML tables/CSS while also having an Accordion, I am getting data from multiple SharePoint lists and displaying it to the page in a JqueryUI Accordion however because it's essentially just a data dump I need to be able to add headers so the users know what data is what. I have created a JS Fiddle of how I tried to do it, with the issues explained below:
http://jsfiddle.net/7uv3m1fy/
The look I am trying to achieve is a set of headers across the top for the parent dataset, with the data from that set being the clickable part of the Accordion. These need the data to line up under the headers. This is pretty much the entire issue I have, they seem to be using only the first of the HTML table on subsequent rows when I want the information to fill all of the columns (preferably with a way to match where the information goes to under it's header)
I honestly don't know enough about CSS or how I could achieve this using DIV's while still being able to get information to line up.
The biggest issue I have is that because the data populating these tables is called from SharePoint lists/views, the number of columns is completely dynamic so I cannot hardcode column width/numbers.
Any suggestion of how I could do this using CSS or HTML or Both would be greatly appreciated.
below is the code I am currently using to generate this (C# as it's for a SharePoint WebPart)
try
{
if (parentItems.Count > 0)
{
newHTML = newHTML + "<Table style='table-layout:fixed' width='100%'><tr>";
foreach (string fieldName in viewFields)
{
newHTML = newHTML + "<td> " + parentList.Fields.GetFieldByInternalName(fieldName).Title + "</td>";
}
newHTML = newHTML + "</tr>";
}
}
catch
{
newHTML = newHTML + "No Results Found";
}
foreach (SPListItem parentitem in parentItems)
{
newHTML = newHTML + "<tr class='yes' width='100%'><td> Parent:</td><td>" + parentitem.ID.ToString() + "</td></tr><tr width='100%'><td>";
foreach (SPListItem childitem in childItems)
{
if (childitem[RelatedID].ToString() == parentitem.ID.ToString())
{
newHTML = newHTML + "<div>" + childitem.ID.ToString() + "</div>";
}
}
newHTML = newHTML + "</td></tr>";
}
newHTML = newHTML + "</table>";
}
And in the webpart I am adding the following to call it:
<div id="accordion">
<%= this.newHTML %>
</div>
I hope I have given enough information, although the code above doesn't really relate to the question it will show you how I am trying to dynamically output the HTML to achieve my goal.
Happy to provide more info if you need it.
Regards,
After weeks of tweaking I finally gave up. I just couldn't fix my multiple file upload on safari, which really bothered me because my code worked perfectly as it should on other browsers, except on safari. Then I have just recently discovered that its not my code that has the problem. Its a Safari bug. Safari 5.1.+ can't read the html5 multiple attribute (or something like that). So users can't use the multiple upload feature, BUT, can properly upload a single file.
few links that discuss the issue:
https://github.com/moxiecode/plupload/issues/363
file input size issue in safari for multiple file selection
It seems that this bug has been around for quite some time. So I was wondering if there are workarounds available for this at the moment that some of you maybe are aware of? Because I can't find any. The only option available i found is to NOT use multiple attribute for Safari 5.1.+ users. Do you guys have any better ideas?
UPDATE
Safari 5.1.7 is the last version Apple made for the Windows OS. They did not continue to build current versions of Safari for Windows. Finding a fix for this bug for me is not necessary since Real Safari users are updated to the latest version of the browser(no facts), and just give a separate upload for those who are still using this outdated version, to not sacrifice the modern features of your application.
This is oldish question, but ... hack-type workaround is below.
Just remove multiple attribute for Safari, turnig it into MSIE<=9 little brother (non-XHR).
Rest of browsers will not be affected.
When Safari finally fixes problem, all you have to do is remove this hack::code and go back to standard input code.
here is standard input sample:
<input class="fileupload-input" type="file" name="files[]" multiple />
jQuery solution:
Just place it somewhere on a page, where you have files input tag.
you may read more here: How to detect Safari, Chrome, IE, Firefox and Opera browser?
$(document).ready(function () {
if (Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor')>0);
$('.fileupload-input').removeAttr("multiple");
});
PHP solution
you will need some code to id browser I used a class I got one in github (MIT)
get it here: https://github.com/gavroche/php-browser
$files = '<input class="fileupload-input" type="file" name="files[]" multiple />';
if (Browser::getBrowser() === Browser::SAFARI) {
$files = '<input class="fileupload-input" type="file" name="files[]" />';
}
echo $files
That is all.
It seems that there is another issue that can be messing around. iOS Safari multiple file uploads always use the name "image.jpg" for all uploaded files. It may seem only one file uploaded in the server side but this is not what happened: it has been uploaded all files with the same name!
So, the workaround comes into the server side: just change the destination filename with a new generated name.
I am working with Flask and Python, so I use the standard formula.
#app.route("/upload",methods=['POST'])
def upload():
files = request.files.getlist('files[]')
for file in files:
if file and allowed_file(file.filename):
filename = generate_filename(file.filename)
file.save( os.path.join(app.config['UPLOAD_FOLDER'], new_album_id, filename))
return render_template('upload_ok.html')
Where generate_filaname has to be a function that creates a new filename with the same extension as the original one. For example:
def generate_filename(sample_filename):
# pick up extension from sample filename
ext = sample_filename.split(".")[-1]
name = ''.join( random.SystemRandom().choice(string.letters+string.digits) for i in range(16) )
return name + "." + ext
The same can be done in PHP, of course.
I ran into the image.jpg problem with asp.net. It may benefit someone. I was appending a non-unique hash to each image file to tie it to the record in the db. Works fine on every platform (our users are using, anyway), except when using Safari. I just appended a hash and a unique three digit string I pulled from the seconds part of DateTime to string:
if (!string.IsNullOrEmpty(ViewState["HashId"].ToString()))
{
string filepath = Server.MapPath("~/docs/");
HttpFileCollection uploadedFiles = Request.Files;
Span1.Text = string.Empty;
for (int i = 0; i < uploadedFiles.Count; i++)
{
HttpPostedFile userPostedFile = uploadedFiles[i];
try
{
if (userPostedFile.ContentLength > 0)
{
string timestamp = DateTime.UtcNow.ToString("fff",
CultureInfo.InvariantCulture);
//Span1.Text += "<u>File #" + (i + 1) + "</u><br>";
//Span1.Text += "File Content Type: " + userPostedFile.ContentType + "<br>";
//Span1.Text += "File Size: " + userPostedFile.ContentLength + "kb<br>";
//Span1.Text += "File Name: " + userPostedFile.FileName + "<br>";
userPostedFile.SaveAs(filepath + "\\" + ViewState["HashId"] + "_" + Path.GetFileName(timestamp + userPostedFile.FileName));
// Span1.Text += "Location where saved: " + filepath + "\\" + Path.GetFileName(userPostedFile.FileName) + "<p>";
InsertFilename("~/docs/" + ViewState["HashId"] + "_" + Path.GetFileName(timestamp + userPostedFile.FileName), ViewState["HashId"] + "_" + Path.GetFileName(timestamp + userPostedFile.FileName));
}
}
catch (Exception Ex)
{
Span1.Text += "Error: <br>" + Ex.Message;
}
}
BindImages();
SetAttchBitTrue();
Button4.Visible = true;
AttchStatus.Text = "This Record Has Attachments";
Button2.Visible = true;
Button3.Visible = true;
Panel1.Visible = false;
}
May be a better way, but we just have a small number of people uploading one - two, maybe three images per record in the database. Should work.
I have a small Google Apps Script that processes a date column in a spreadsheet and generates entries in a Calendar (birthdays).
Work is fine, but when adding reminders to the (recently-created) CalendarEvent, an error is thrown :
Service error: CalendarApp: Mismatch: etags = ["GUQKRgBAfip7JGA6WhJb"], version = [63489901413]
I've tried to perform 1 second sleep after creating event (wait for changes to be done in calendar), but no luck on this...
BTW, events are created succesfully, only reminders cannot be added.
PD: the calendar is one I own, but not my primary calendar.
Here is part of the code:
try
{
birthday = new Date(Data[i][BirthColumn]);
birthday.setFullYear(today.getFullYear());
birthday.setUTCHours(12);
birthlist += Data[i][NameColumn] + " --> " + birthday + "\n";
calendarevent = cal.createAllDayEventSeries("¡Cumpleaños " + Data[i][NameColumn] + "!", birthday, CalendarApp.newRecurrence().addYearlyRule().times(YearsInAdvance));
if (calendarevent == null)
success = false;
else
{
//This sentence fails every single time.
calendarevent.addEmailReminder(0);
calendarevent.addPopupReminder(0);
calendarevent.addSmsReminder(0);
}
}
catch (ee)
{
var row = i + 1;
success = false;
errlist += "Error on row " + row + ": check name and birth date. Exception Error: " + ee.message + "\n";
}
This is the portion of the code I finally change to make it work, as Serge insas suggest me before:
if (calendarevent == null)
success = false;
else
{
cal.getEventSeriesById(calendarevent.getId()).addEmailReminder(0);
cal.getEventSeriesById(calendarevent.getId()).addPopupReminder(0);
cal.getEventSeriesById(calendarevent.getId()).addSmsReminder(0);
}
This is a known issue
See comment nr 67 for a working workaround : the trick is to re-call the event for every item you want to add (reminder, popup...) using cal.getEventSeriesById(eventID) after you get the Id simply with .getId()
I use it in some scripts and it solved the issue for me.