Solved

Sending Email using Javascript

Posted on 2013-01-14
11
222 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
  • 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

786 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