Solved

Sending Email using Javascript

Posted on 2013-01-14
11
209 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 82

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
 

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 82

Expert Comment

by:Dave Baldwin
ID: 38784393
You didn't attach anything.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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 82

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now