Solved

Sending Email using Javascript

Posted on 2013-01-14
11
259 Views
Last Modified: 2013-03-27
I am getting a debug error stating ";" missing colon. This code does not work. I am using classic asp

  function SENDRMS()
        {      
            set myMail=CreateObject("CDO.Message")
            myMail.Subject="Commercial Loan Advance Draw"
            myMail.From="druffin@anchorbank.com"
            myMail.To="druffin@anchorbank.com"
            myMail.TextBody="This commercial loans needs to be approved."
            myMail.Send
            set myMail=nothing
        }




<input id="RM" type="button" value="Click Here to Send TO RM's Approve" onclick="javascript:SENDRMS();"
                                                      NAME="RM">
0
Comment
Question by:DevoinIT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 2

Expert Comment

by:ConnerT
ID: 38775780
You can't send an email directly with javascript.

However you can open the user's mail client:

window.open('mailto:test@example.com');

There is also some parameters to pre-fill the subject and the body:

window.open('mailto:test@example.com?subject=subject&body=body');

Hope That Helps !
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 38775822
It looks like you are trying to use javascript in the browser to call an ASP routine on the server.  That simply isn't allowed.  You can create a link to the page with the ASP routine like <a href="SENDRMS.asp">Click Here to Send TO RM's Approve</a>.
0
 
LVL 1

Expert Comment

by:devoinr
ID: 38776137
can I get a example of the page route href
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

Author Comment

by:DevoinIT
ID: 38784386
I have created this sendmail.inc and I am including this into my asp page. I keep getting the end of statment error and I can not find what is going on. I have attached my the page I am trying to send.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 38784393
You didn't attach anything.
0
 
LVL 1

Expert Comment

by:devoinr
ID: 38784416
The attached file should be sendmail.inc but it not in the list of possible upload files so I changed the extension. I have bee just trying to send a email. Please review this and let me know.
SendMail.txt
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 38785305
That code assumes that there will be a SMTP server to send email on the local computer.  In most cases, that is not going to be true so it won't work most of the time.
0
 
LVL 1

Accepted Solution

by:
devoinr earned 500 total points
ID: 38787434
I have added this code and I still get the end of statment error. The error is comeing from the Input.

<INPUT ID="btnSend2" TYPE="BUTTON" VALUE="Click FOR Signature" onclick="VBscript:Send();">


Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "druffin@anchorbank.com"
objMessage.To = "druffin@anchorbank.com"
objMessage.TextBody = "This is some sample message text."

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.anchorbank.com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoAnonymous



'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objMessage.Configuration.Fields.Update


objMessage.Send
0
 
LVL 1

Expert Comment

by:devoinr
ID: 38788748
Dave
You were right about the SMTP I have it working right now.
Thanks
0
 
LVL 1

Expert Comment

by:devoinr
ID: 38798951
I awarded the points to Dave
0
 

Author Closing Comment

by:DevoinIT
ID: 39027447
This was a good responds
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question