This topic is locked

Adding a second function to the Save button

10/4/2006 11:00:17 AM
ASPRunnerPro General questions
N
ninja author

Hi there, is there any way to add a second function to the 'Save record' button. I'd like to save the record and send an email notification to inform a user xxxx@xxx.com that a new record was added.
Is there an easy way of doing this?
Thanks
Dave

Sergey Kornilov admin 10/4/2006

Use BeforeEdit event. Use sample event code "Send an email".

C
clig 10/5/2006

Hi there, is there any way to add a second function to the 'Save record' button. I'd like to save the record and send an email notification to inform a user xxxx@xxx.com that a new record was added.

Is there an easy way of doing this?
Thanks
Dave


You could also use VBScript on the "edit" page for example:
<script language=VBScript>

<!--

Sub SendMessage

Dim engineeremail

engineeremail = document.editform.Engineer.value

engineeremail = mid(engineeremail, instrrev(engineeremail, "\")+1)

Dim salesemail

salesemail = document.editform.Email.value

Dim RequestDate

RequestDate = document.editform.Requested.value

Dim ESRID

'ESRID = document.editform.TrackingNumber.value

Dim objOutlook ' AS Outlook.Application

Dim objOutlookMsg ' AS Outlook.MailItem

Dim objOutlookRecip ' AS Outlook.Recipient

Dim objOutlookRecipCC ' AS Outlook.Recipient

Dim objOutlookSubj 'AS Outlook.Subject

Dim objOutlookAttach ' AS Outlook.Attachment
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg

Set objOutlookRecip = .Recipients.Add(engineeremail)

Set objOutlookRecipCC = .Recipients.Add(salesemail)

.Subject = "New ESR Assigned"

.Body = "This is an automatically generated email sent by the Engineer that assigned a new ESR to you and the Sales Rep that generated it has been copied on this email. http://onapp005/SALESandENG/. Tracking #: " + document.editform.editid.value + " Submitted: " + document.editform.Requested.value + " Customer Name: " + document.editform.Customer.value + " Address: " + document.editform.Address.value + " Project Number: " + document.editform.[Project #].value

objOutlookRecip.Type = 1

objOutlookRecipCC.Type = 2

.Display

End With

Set objOutlook = Nothing

End Sub

-->

</SCRIPT>
<script language=vbscript event=onclick for=submit1>

<!--

SendMessage()

-->

</SCRIPT>

Hi there, is there any way to add a second function to the 'Save record' button. I'd like to save the record and send an email notification to inform a user xxxx@xxx.com that a new record was added.

Is there an easy way of doing this?
Thanks
Dave


Another is to call another asp page
<script language=vbscript event=onclick for=submit1>

<!--

Open.window.location.href = "http://ONAPP005/WebESREmail.asp";

-->

</SCRIPT>
WebESREmail.asp sample
<%@ LANGUAGE="VBScript" %>

<HTML>

<HEAD>

<%
remuser=Request.ServerVariables("REMOTE_USER")
'response.write "ru:" & remuser

'response.flush
Dim ObjSendMail

Set ObjSendMail = CreateObject("CDO.Message")
'This section provides the configuration information for the remote SMTP server.

'servers:

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing";) = 2 'Send the message using the network (SMTP over the network).

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver";) ="emailserver"

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport";) = 25

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

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout";) = 60
' If your server requires outgoing authentication uncomment the lines below and use a valid email address and password.

'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate";) = 1 'basic (clear-text) authentication

'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername";) ="somemail@yourserver.com"

'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword";) ="yourpassword"
ObjSendMail.Configuration.Fields.Update
'End remote SMTP server configuration section==
dim db

'DSN-less connection

Dim objRecordSet

Set db = Server.CreateObject("ADODB.connection")

db.ConnectionTimeout = 25

db.Provider = "sqloledb"

db.Properties("Data Source").Value = "ServerInstance"

db.Properties("Initial Catalog").Value = "Database"

db.Properties("User ID").Value = "sa"

db.Properties("Password").Value = "foobar"

db.Open

Set objRecordSet = Server.CreateObject ("ADODB.RecordSet")

objRecordSet.Open "SELECT tp_Login, tp_Title, tp_Email FROM userinfo WHERE tp_Login = '" & remuser & "'", db
objRecordset.movefirst

tp_Login = objRecordSet("tp_login")

tp_Title = objRecordSet("tp_Title")

tp_Email = objRecordSet("tp_Email")

ObjSendMail.CC = tp_Email

'response.write "<BR>cc:" & tp_email

'response.flush
ObjSendMail.To = "email@email.com"

ObjSendMail.Subject = "New ESR Submitted"

ObjSendMail.From = "emailer@email.com"
' switch the comments around to send an html email instead

ObjSendMail.HTMLBody = "Reps: <a href=http://onapp005/SALESandENG/>http://onapp005/SALESandENG/</a>&nbsp;&nbsp;&nbsp;&nbsp;Select My ESR Status Bar and ESR Editing Tools&nbsp;&nbsp;&nbsp;&nbsp;Engineers: <a href=http://onapp005/SALESandENG/Engineering/>http://onapp005/SALESandENG/Engineering/</a>";

'ObjSendMail.TextBody = "http://onapp005/SALESandENG/Engineering/";
ObjSendMail.Send
Set ObjSendMail = Nothing

%>

<title>

Email Notification

</title>

<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">;

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<script language="JavaScript">

<!--

window.moveTo(0,0)

window.resizeTo(200,300)

// -->

</script>

<script language="JavaScript">

<!--

defaultStatus = "Support Team Web Site (NTSS-Web) 1999-2006"

// -->

</script>

</HEAD>

<body bgcolor="#e1f5ce" bgproperties="fixed" bottommargin="0" topmargin="0" scroll="no" class="WebESR">

<P>Email has been sent to Engineering informing the group of a new ESR that has been submitted to queue. You can close this window at anytime.</P>

</body>

</HTML>

N
ninja author 10/6/2006

Use BeforeEdit event. Use sample event code "Send an email".


I was stuck as to where to find this function, I should've said I was using ver 2.4 - I've upgraded to ver 4 and all becomes clear <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=11645&image=1&table=forumreplies' class='bbc_emoticon' alt=';)' />
Cheers
Ninja <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=11645&image=2&table=forumreplies' class='bbc_emoticon' alt=':ph34r:' />

N
ninja author 10/6/2006

hmmm still not working <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=11654&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' /> , I've used the in built template as this is all I require.
I've set the smtp server, port and login details in the security page, but when I try it no mail is created nor sent. we use our own server and looking at the mail logs there is no attempt to send the mail.
any ideas?
Thanks
Ninja <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=11654&image=2&table=forumreplies' class='bbc_emoticon' alt=':ph34r:' />

N
ninja author 10/9/2006

<bump>

Sergey Kornilov admin 10/9/2006

You can send your files to support@xlinesoft.com for investigation.

N
ninja author 10/12/2006

You can send your files to support@xlinesoft.com for investigation.


Sent <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=11808&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
cheers
Ninja <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=11808&image=2&table=forumreplies' class='bbc_emoticon' alt=':ph34r:' />