Send outlook email with JS? - javascript

I want to send a email automatically with JS.
I use the next code to open a window with outlook with a mail with the information that I want.
Now I want to send the mail with JS. I need to "click" the send button automatically of the Outlook interface. Any ideas? Maybe with an Ajax /JQuery?
If anyone knows other process to send emails automatically with JS its usefull for me too.
function main(){
location.href = "mailto:"+'someone#something.com'
+'?cc='+" "
+'&subject='+'something'
+'&body='+"Hi, im an automatic mail";
}

To details
Please note, JS is client side and runs inside browser, you do not have access to any application or file system outside browser or to browser itself..
Further,
If you need to send automated emails, you will need server side email engine configured and will need to make ajax / jQuery call to engine with recipient details..

Related

Invoke outlook from javascript & send mail automatically

I have a scenario if the user clicks submit button mail should be sent automatically through outlook without POP-UP(asking for us to click send button).
How to do this & is der anyway to access outlook api for auto sending a mail.
There is, but not using Javascript. Outlook has a COM interface (and probably .NET as well) which allows sending e-mails, but it will show warnings as well. The only way is to actuall build an Outlook add-in that can send e-mails 'from the inside'.
To help you build this, you can use Outlook Redemption, which provides Outlook-like functions that can be called without the warnings. But as far as I know, there's no way to control Outlook from outside to send mail and especially not from Javascript.
This measure is taken to prevent malicious scripts sending spam using your Outlook.

Java scripts not working in html email template

I have a scenario where I need to send an email using c#, which could be easily done using SMTP, but the challenge is to incorporate web service in the html mail, hence i have used java scripts inside mail body to access the web service when a button click is raised.
As a html(Web Page), it works perfectly good but then when i send a mail and try with the click of a button in my mail, the onclick not raised the jscript and hence no action has happened and it was actually disabled.
I checked with the firebug(in firefox) in the particular html tag, to my surprise the jscript tag was not present there hence the event was not raised. My question is can we access web service in html email? and don't JScripts works on Gmails?
Does the html email do only the redirecting, using href... To my experience i have never got any mail which uses java scripts(like click of a button zooms the image in the same page, which is very much possible in html,asp pages). Thx in advance...
Apart from struggling to understand the question, Javascript won't work in most mail clients. Deliberately disabled.
You can't automatically call a web service from an e-mail letter. You have to create an URL for the recipient to open, and let them access the web service from a web page in the browser.
JavaScript, and any other third party communication method for that matter, is disabled in any reasonable e-mail client by security reasons.
I'm not aware of any email client or web mail service that will execute JavaScript embedded in an HTML email.
Limit HTML use in emails to formatting. If you need an web application, then link to it instead.

JavaScript Facebook Fan Gate without Permissions

I'm in the process of building a fan gate using facebook's javascript sdk. I'd like to determine if the user has "liked" my page so I can display / hide content. Currently, if I use the javascript sdk, the user is prompted with permissions which is what I'd like to avoid.
Has anyone successfully achieved this in javascript? I'm able to do this without issue in PHP but unfortunately, we are not able to use php in our current project.
This is not possible on the client side. Facebook sends an HTTP POST request and you need to process the signed_request post variable which requires server code to access.
If you are doing it in a Facebook tab, you can use the PHP SDK and read the signed request:
$request = $facebook->getSignedRequest();
$isFan = $request['page']['liked'];
If you are not in a tab, there is no reliable way of checking "like" status without permissions.

Emailing from Javascript

I know this topic has been covered from all sorts of angles but I'm not sure I've seen the answer to my specific question.
I am writing a prototype web page in HTML5, CSS, and Javascript. I want the user to be able to browse to a file to attach then attach that file to an email I send to a specific email address I've setup. I don't want the user's default email program to pop up.
I have addresses to SMTP servers within my companies intranet but I don't have access to a server at the moment to put server-side code on. On the web page the user will know email is involved but I don't want them to have to do a thing other than select the file and click a button with no other screens popping up.
I know how to use mailto in order to send an email but I don't think you can use that with attachments.
Is there anyway to do this without having to mess with the server side? Is knowing an smtp server address that I have permissions on enough? Again, this is a prototype but possibly the basis for a new feature on a product.
Thanks!
Is there anyway to do this without having to mess with the server side?
Nope, not unless the target browser has exposes an SMTP client object. (And I don't think any do. That would make spam botnets quite a bit easier to build...)
You need to do this on the server.
Email cant be sent just by client side . You must either use a mailto link if you want it on client side but that's not best way . Instead you should send a request to server and do server side processing .If you have SMTP credential you can send email with server side.
I recently wrote a plugin for PostageApp that lets you send emails through jQuery. Basically, you just have to feed it your API key along with the message payload and you can send it through. With PostageApp, you can add your SMTP servers to the app and send through them.
Usage looks like this:
<script type="text/javascript" src="postage.js"></script>
<script type="text/javascript">
$(function() {
$('p').postage({
apiKey: "API KEY HERE",
recipients: "recipient#email.com",
template: "TEMPLATE_SLUG" });
});
</script>
I didn't publish the plugin because well... it never made sense for production usage because your API key was exposed and that's not a good thing. However, it is decent for prototyping (I use it!) and I would be happy to share.
(Full Disclosure: I am the Product Manager of PostageApp.)

Send a web page through javascript

I want to email a web page through javascript. Its enough to open the outlook new mail option. I try to move a Here i am using mailto: option in html.
Actually i am try to create a dynamic email template and want to send that template in html format.
Its showing error "comment line argument is not valid. verify the switch you are using"
please get me the solution.
Javascript can't send e-mails. Your best bet is the e-mail me syntax. There is a convention that most browsers suppors that lets you set the contents of various attributes as well.
e-mail me
It will have to be URL encoded, and as far as I know, there is no reliable way to pass HTML. You have to assume plain text emails.
You really need the server's help to make this easier.
1) Have the server make an XMLHTTP request to the page that generates the HTML you want. Grab it and make it the mail body.
or -
2) Grab the innerHTML, stick it in a hidden textarea and post it back to the server. Use the posted form field in the mail body.
You need to do this server-side, not client side. Outlook is not going to allow you the control you need to use a template. And for good reason - you wouldn't want websites taking control over your Outlook and sending emails.
If you can tell us what server you're using, we can show you how to send the email server-side.
There are security restrictions which stop it working directly. Yes if you wanted Outlook specifically, you could start messing with ActiveX - but that is fiddly and limited certain operating systems , installations, and security settings.
It is much better to use a mailto: URL. This is then cross-platform, and supports any default mail client.

Categories

Resources