Solved

Sending Email using Javascript

Posted on 2013-01-14
11
247 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Jquery form 9 62
Aspx calendar pop up control 3 35
Error Handler 8 38
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given PHP 5 34
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

738 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