This topic is locked

Email with Outlook

10/30/2006 3:24:55 PM
ASPRunnerPro General questions
P
pharaon_98 author

Hi everyone
I'm trying to modify the ...edit.asp page to add a button that will open up Outlook with certain data from the database (clients email adress, record no)
What i really need is that once the button is pressed, it's going to open up Outlook with the to : filled with the email adress of the client (from the database), the subject (plain text i can add myself) and the body containing an hyperlink with the record no.
It could also be an after record update events (which is even better) or a button directly on the edit page.
I'm a complete newbie to ASP.
I also tried with the view as from a ...view.asp page but couldn't add the body and subject line...
thanks

J
Jane 10/31/2006

Hi,
you can place link on the Edit page with the following EditOnLoad event:

Sub EditOnLoad()

str = "select * from TableName where " & where

Set rsTemp = server.CreateObject("ADODB.Recordset")

rsTemp.open str, dbConnection

Response.write "<a href=""mailto:" & rsTemp("email") & "?subject=Yoursubject&body=yourbody "">Click to send record info!</a>"
End Sub



where email is your actual field name.

P
pharaon_98 author 10/31/2006

Yahooo!
Works like a charm.
Only one problem left, and everyone will think i'm a genius.
Thanks a lot

C
clig 11/26/2006

In your *edit.asp page:
To access Outlook directly you could also do something like this - this is a sample based on a drop down value change for a field named "Completed"
<script language=VBScript>

<!--

Sub SendMessage

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 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(salesemail)

.Subject = "ESR Completed by Engineer"

.Body = "This is an automatically generated email sent by the Engineer that has just completed your ESR. 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

.Display

End With

Set objOutlook = Nothing

End Sub

-->

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

<!--

SendMessage()

-->

</SCRIPT>
****
now to trigger Outlook from the "Save" button
<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>
*Depending on client security settings Outlook may pop a dialogue box asking for permission to access itself

  • This process allows the user to modify email prior to sending or simply click send as is...
    Hi everyone

    I'm trying to modify the ...edit.asp page to add a button that will open up Outlook with certain data from the database (clients email adress, record no)
    What i really need is that once the button is pressed, it's going to open up Outlook with the to : filled with the email adress of the client (from the database), the subject (plain text i can add myself) and the body containing an hyperlink with the record no.
    It could also be an after record update events (which is even better) or a button directly on the edit page.
    I'm a complete newbie to ASP.
    I also tried with the view as from a ...view.asp page but couldn't add the body and subject line...
    thanks