I am trying to send an email, from sqlserver, that has html form elements like textfields and buttons.
Here is my script
Declare #Body varchar(max)
set #Body = '<html>
<body>
<form action="http://localhost:8080/Email_test/TestServlet.do" method="post">
<input type="text" name="test_input" id="test_input" value=""/>
<input type="submit" value="update"/>
</form>
</body>
</html>
'
exec sp_send_dbmail
#profile_name = 'test_profile',
#recipients='me#example.com',
#subject = 'This is a test form',
#body = #Body,
#body_format = 'HTML';
The above script works fine and sends an email to the intended recipient with one problem.
The form elements are not present in the mail and a message is displayed at the very top of the mail that says "if the message of this mail is not displayed properly click here to open it in a web browser".
I am using microsoft outlook 2010.
Is there a way to make these form elements render in the mail itself, instead of going to the browser..?
The HTML form tag is not supported in Outlook from 2007, including in Outlook 2010. Its considered a security risk.
Actually its not a SQL-Server issue, its a email client issue. As you can see in the image below, lots of clients don't support the form tag.
image from this url: http://css-tricks.com/html-forms-in-html-emails/
After some research, it is evident that outlook mail client doesn't support the form tags and other elements like a button or textbox. But the form element and other input elements work when you use the online version of outlook OWA.
But in OWA also scripts won't get executed. In the desktop version, there will be an option to view the message in the web browser, which will render everything fine just like a web page.
As pointed out by others, there appears to be some serious levels of security issues. For instance, there is no way to authenticate if the form is submitted by the intended recipient. Anybody with access to the html code can just fill it and submit it as there is no method to authenticate the submitter.
Microsoft Infopath or outlook's custom forms can be used for this purpose.
Related
I'm setting up a solution for a backoffice website where the user should be able to send mail for some technician.
In this mail, the technician must be able to click on a specific button and this will open a new web page with adaptative parameters such as the date, the address, the client name, etc..
To do so, I need to send at least one parameter in the mail (the mission id of this technician) and this parameter must be different in each mail.
I already tried a solution in which the mail is written in HTML and then I could insert a form in the body or a link for a GET request. But it seems that not all the mail server can handle this way of work.
In Gmail it works for everything, but using Safari for Mac OS X, or Outlook messenger it doesn't.
Using POST:
<form action='__the_website_to_post_request__' method='post'>
<input name='id' type='hidden' value='$id'>
<button type='submit' formmethod='post'>Upload reports</button>
</form>
Using GET:
<a href='__the_website_to_post_request__?id=".$id."&tok=".md5($id)."'>
Upload reports
</a>
In Outlook, no button appears and in Safari, the post method doesn't work.
Maybe another solution exist doesn't matter which mail application I should use ?
I'm looking for a code that sends a pre-written, formatted email when a link is clicked (Wordpress)
I tried this:
YourName#YourSite.com
But there are two problems with it
It only works if the person clicking the like has an offline email client configured like Outlook or Thunderbird.
It doesn't format the email correctly, and doesn't include any links
I was wondering if I can use Contact form 7 with placeholder? Also, will it send the email from single IP address?
It only works if the clicker have any offline email client configured like Outlook or Thunderbird
Thats how mailto: works. It will open in the default mail client installed in your computer.
It doesn't format the email correctly an doesn't include links
Try the below code.
var emailBody = "1st line.\n 2nd line \n 3rd line <a href='http://yahoo.com'>Yahoo</a>";
emailBody = encodeURIComponent(emailBody);
href = "mailto:me#somesite.com?body=" + emailBody;
Set this href variable to the href attribute of your a tag
document.getElementById("mailme").href = href;
You can configure the email templates that contact form 7 sends out in the 'Contact' section of your wp-admin panel. Yes, they will all come from one IP address, that of your server, but unless you're expecting thousands of mails every hour to be sent from it, that's hardly going to be a limitation.
How can I open the default compose mail window from the user's mail app from within a Qt app?
I found there is some class for mobile with Qtmobility, but I don't have access to this class as I'm working on a desktop app.
I also found people to use a URL sheme with a mailto in it. This isn't working for me because the html is stripped at some point, probably because of the url being too long and the html is not rendered in html but in plain text.
How can I precompose a mail in Qt and open the default mail app?
There is no built in way in Qt to send email with HTML formatting. The Mailto method will work for unformatted text, e.g.
QDesktopServices::openUrl(QUrl("mailto:?to=recipient#example.com&subject=The subject of an email&body=Here is some email body text", QUrl::TolerantMode));
But this cannot be used for html formatted text.
If you absolutely need HTML you will need to look at the options for your platform(s):
MAPI for Windows
AppleScript and Mail.app on OSX
Mail on Linux
Old topic but :
You could also try another way, as I did, using a web service.
I have a php web service that send email to a specific mail address, so I just send the message data to this web service, that will handle the rest for me.
This is to abstract yourself of using a desktop software that most of the time users don't have ( we all use gmail anyway, so you know ... ).
In php :
// sending mail to my#address.com
$headers ='From: sender#address.com'."\n";
$headers .="Reply-To: replyto#address.com"."\n";
$headers .='Content-Type: text/plain; charset="iso-8859-1"'."\n";
$headers .='Content-Transfer-Encoding: 8bit';
mail('my#address.com', '[TAG] mail subject', "some body text.", $headers);
Careful of security though !
My ActionHandler.ashx file should be POSTed yet upon entry to ProcessRequest the context.Request.RequestType is always "GET".
Background:
This HttpHandler currently works OK (i.e. clicking a link in an email causes my ActionHandler.ashx to be entered and the querystring is processed correctly). For example:
https://mdwdata/CorporateBrain/ActionHandler.ashx?Action=MarkComplete&ID=1024~nzmewoojgnn&CUID=13
is the URL for the link shown as Mark-Complete in the image just below:
But now I am trying to improve it by following this advice in a previous SO thread :
"In the body of the email, instead of sending a link, include an HTML form that contains a button which performs a postback to your server."
Problem Summary: When I click the Submit button, my handler is entered with verb GET not POST (hence, I have no access to the hidden form data in the Request.Form collection.
Here is a snippet (image) of the email body
If I can get the Submit to post the hidden form variables to my handler, then of course I would remove the links. In the debugger, I verified the form data and it looks good me:
I added this line to my web.config file:
<add path="ActionHandler.ashx" verb="GET,POST" type="System.Web.UI.SimpleHandlerFactory" validate="true" />
Also, my email client is Thunderbird.
What would cause the request to be GET instead of POST?
The short answer to this problem is that Thunderbird does not POST to the URL in the Action attribute of the HTML form tag. Even the newest version of Thunderbird (version 31.2.0) "ignores" the POST and requests the URL via GET.
The construction of the HTML form is properly done and other email clients I have tested work fine:
Microsoft Office 365 Outlook Web App
Google GMail
So, I guess I am doing it "right" but some email clients apparently don't support this (even my favorite which is Thunderbird).
I have a website which I want users to be able to share a link via email. This particular page is the mobile version.
I have an asp:button using mailto and I need to pass variables from the page to build the URL in the email body.
<asp:Button ID="btnEmail" runat="server" Width="70%" Text="Share Property" PostBackUrl='<%#"mailto:?subject=Check out this property at xxx - " & DataBinder.Eval(Container, "DataItem.PropertyName") & "body=" & DataBinder.Eval(Container, "DataItem.PropertyID")%>'/>
The mailto is working and the subject is populating but the mail body seems to contain the viewstate of the page:
__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUKMTM4ODYwNDQ2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PDxYCHwIFHFJlcXVlc3RWaWV3aW5nLmFzcHg%2FSUQ9UDEzNDFkZAIHDw8WAh8CBWNtYWlsdG86P3N1YmplY3Q9Q2hlY2sgb3V0IHRoaXMgcHJvcGVydHkgYXQgSm9obiBXaGl0ZW1hbiAtIFJlZHdvb2QgQ2xvc2UsIFNvdXRoIE94aGV5Ym9keT10ZXN0UDEzNDFkZGQlH8aveHqM96GJK6rcUKFtYormuw%3D%3D&__PREVIOUSPAGE=jXBhZExXbPAJGCoKEgVxPvQrYIK2wX4xu1Pu8m0He281&__EVENTVALIDATION=%2FwEWBQLLnPHNBQKLm%2B%2BxDQKTlZGGAQKbi8jQCALB16nOAksIgJxExXvoFLdOr%2FT%2F56iiVmxW&ctl00%24MainContent%24myDataRepeater%24ctl00%24btnEmail=Share+Property
Where am I going wrong?
A Button wants to do a postback, which contains all form fields.
You can also use a <a href="mailto:..."> to initiate an e-mail from the user's mail program. You don't need the runat=server here.
You can style that link to look like a button.