Auto generate a partly trimmed email - email

I'm developing a message client and I need to auto generate an email on the server and send it to the user each time a new message gets posted in the message client. The email should have the latest message in the top and the rest of the conversation in trimmed form after the latest message.
In Gmail it's displayed as an ellipsis icon [...] that expands on click. Is there some kind of "standard" amongst email clients how to achieve this and what characters or html do I need to include in the email body?
I've tried things like below, but can't get it to work.
Latest message
>> Earlier message 1
>>
>> Earlier message 2
>>
>> etc...

What are we talking about here? HTML? You could use something like jQuery and replace the div each time it is clicked.
$( "#earlierMessage1" ).click(function() {
$('#earlierMessage1').html(earlierMessage1Contents);
});
A lot more info needed either way I'm afraid.

Related

Apps Script is adding line breaks to email bodies

I am generating emails with Google Apps Script and the emails are being sent with line breaks in weird places.
Here is my code
function sendEmail(){
var name = "MyName"
var body = name + " has issued a challenge. You already have a match currently scheduled so you have the option to decline. Reply to this email with the word 'ACCEPT' or 'DECLINE' in the subject." +
"\n\nNOTE: If you do not respond to this email you will automatically accept the challenge and be responsible for scheduling the match within two weeks or suffer a forfeit."
GmailApp.sendEmail("MyEmail#gmail.com", "You've been challenged!", body)
}
You'll notice that it is also putting the text of the first section of the body in a purple color. I also don't know why this is happening but my priority is to stop the line breaks from being put where they shouldn't be.
Google 'Stacks' emails. Say for example I send you an email. Then you reply and I reply again. It stacks them all into one line in your inbox.
Any identical paragraphs in the emails are made purple. Only you see the purple.
If you delete all of the emails out of your inbox and test again, you should notice it in black.
Also, you have code to create two new lines. '\n' x2. You're essentially creating a new paragraph, do you just want a new line to begin instead? If so delete 1x '\n'. Sorry if I'm not understanding your issue.
If you were to insert the body as html and use paragraph tags you would likely be able to achieve the results you are pursuing.
I am on mobile and don't know how to get resource links to prove the above sorry.
Edit: I would make the following change:
body = name + " has issued a challenge. You already have a match currently scheduled so you have the option to decline. Reply to this email with the word 'ACCEPT' or 'DECLINE' in the subject." + "\n\n" + "NOTE: If you do not respond to this email you will automatically accept the challenge and be responsible for scheduling the match within two weeks or suffer a forfeit."
Your code is including the body as plain text so it is automatically cropped at certain line length. Below some questions about the same "problem"
Gmail API - plaintext word wrapping
Why isn't Gmail using quoted-printable encoding?
If you want to have more control about how the message content looks on Gmail, besides sending the content as plain text sent it as HTML. For doing this use
sendemail(recipient,subject,body,options)
Related questions about using the above method:
Sending an email in HTML and plain with a Gmail Apps Script

(drupal) Webform2pdf blank submitted data tokens when PDF send by mail

I run into an issue with module webform2pdf, which I am too unable to solve for a few days. I am using Commerce Kickstart as a drupal commerce module for handling all the shopping fuctionality, and we were in need to add webforms for returns policy (required by law in my country).
This form has many fields, like when you have pursached the product, what is it's serial number etc. Webform2pdf module was used for sending submitted data as PDF as attachment to email. But the received PDF by mail has blank data tokens, no matter how I try. Weird thing is, that when I hit download PDF in administration of drupal website, it just fills the data tokens right.
I have tried many tokens, all of these:
[submission:values:meno:withlabel]
[submission:values:meno]
[webform:val-meno]
[webform:meno]
%email[meno]
%email_values
%label_nl[meno]
%nl[meno]
%label_all[meno]
%label_all_nl[meno]
%all[meno]
%all_nl[meno]
[submission:values]
%value[meno]
Neither of them works, most of them simply prints token label. For example [submission:values] prints all the labels, but no data.
Upper in the mail, I have also token:
%label_all[typ_servisu]
Which prints correctly when sent via mail, but refuses to print when "download PDF" in administration. This token holds select radio buttons.
I have also tried send pdf as attachment via Rules, but with no success. I am not very experienced developer.
Any advice would be greatly appreciated. Thank you.

Is it possible to hack mailto?

Sorry about the provocative subject but I could not think of a better word than "hack" to describe what I would like to do!
On my site, I provide links to other sites and on request by the user, display a page from the site in a frame or pop up window. Frequently these displayed pages have a mailto-tag.
I have found it extremely annoying that clicking the mailto link starts off my outlook which I no longer use but retain it as an installed program on my machine.
What I would like to do is:
1) Pick up the subject and email address part of the mailto tag.
2) Pop up an HTML form where the email address and the subject is prefilled.
3) Send the email message through my site's mailserver instead of through outlook or any other mail client.
Is there a way to do this?
Thank you in advance - and once again apologies for the provocative subject line!
Cheers!
Uttam
Try it using javascript.
With using a framework like jQuery its easy so find such tags inside a frame or popup window.
You can try it by something like this:
var allATags = $('myFrameId').find('a');
$(allATags).each(function(index, element){
var href = $(element).attr('href');
//here you shall try to find out if there a mailto Link or a normal link, e.g. using regular expression or indexOf()
[...]
if (isMailToLink){
//split the href String at the signs '&' with which the subject, mail, etc is splitted and removing the mailto, putting all in own variables
[...]
$(element).attr('href', 'javascript:void(0);');
$(element).click(function(){
showMyMailForm(toMail, mailSubject, mailBody);
});
}
});
On opening a document in a frame or a popup wait for the document being loaded and then run your code to replace all existing mailto-links on that document with your mailform-mailer.
The code is just a way trying to inspire, no working code.
Users can set their default email client, here are a couple of links that may be helpful:
Firefox
Chrome
Internet Explorer
Of course this is controlled by the user, so it will help you personally, but not force others to use a specific program.
You could easily pass url parameters onto your contact landing page/email form instead of a mailto link, something like a href="http://landingpage.com/index.php?email=you#you.com&subject=hello" could be used to pre-fill generic contact/email form fields.

Win8/WinRT - How to add line breaks in email body

In my Windows 8 Store app, I have a Send Email button on a page and users are able to click it and send us an email for some general enquiries.
I need to pre-load some text in the email body but I can't seem to add line breaks to it. I tried Environment.NewLine and "\r\n". None of them works.
var mailto = new Uri("mailto:?to=james.jones#example.com&subject=Hello world&body=Hi," + Environment.NewLine + "Can you please ...");
await Windows.System.Launcher.LaunchUriAsync(mailto);
When I run it, I get "Hi,Can you please...". The line break is omitted.
Try using "%0d%0a" as your line break, as in
"Hi,%0d%0aCan you please..."
That's a URL-encoded ASCII CR/LF sequence. That works for me for the built-in Mail app but you don't have any particular guarantee that it would work for any arbitrary mail app that the user might install in the future.
The reason it doesn't work is because you're launching a Uri, Uris require that their contents be UrlEncoded / UrlEncodable. In the case of Environment.Newline etc you'd get an invalid Uri.
You can counter this by UrlEncoding the Environment Newline like this:
System.Net.WebUtility.UrlEncode(Environment.NewLine)
You maybe should consider using a Share Contract to share your content to your Mail App. Benefits: Users using your software can share it to other Apps, not only Email.

How to get the received email with spaces in CAKEPHP?

In my cakephp website i have a controller which handles a simple contact form. But i have a problem! If in the contact_controller.php code i use:
$this->Email->send($this->data['Contact']['message']);
i receive the email in my mail box with linebreaks like the user wrote the message. But if i use:
$this->Email->send();
and create an html template to get the variables that i want to receive in mail, i will receive the same with no linebreaks.
How i can fix that?
Which one do you want? In the first case you send a plain text email, so you will have your line breaks in place.
In the second place you send HTML e-mail, where line breaks are in place, but simply ignored.
So either keep sending mails plain text or use nl2br() function on the body for html output.