Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Access Page - Sending email

Status
Not open for further replies.

Tamrak

MIS
Jan 18, 2001
213
US
Hello,

I created Data Access Page and put one command button to send an email when the table has been updated. I continued getting an error.

The button that I put on the page was to save the record and send an email notification. I call it, "SaveandSent."

The script that I have behind the button is the following: (The button name is "SaveandSent.")

The scripts are below:


<SCRIPT language=javascript event=onclick for=SaveandSent>
try { if (MSODSC.DataPages.Count > 0)
if (MSODSC.CurrentSection == null)
MSODSC.DataPages(0).Save();
else
MSODSC.CurrentSection.DataPage.Save(); }
catch (e)
{ alert (e.description);}

const olMailItem = 0
Dim oApp 'As New Outlook.Application
Dim oMail 'As Outlook.MailItem
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(olMailItem)
oMail.To = ("My Email@mydomain.com")
oMail.Subject = ("Record has been updatedl")
oMail.Body = ("The table has been updated with a new record.")
oMail.Save
oMail.Send

</SCRIPT>

When I saved the scripts in vbs file, it was running fine. I am using Outlook as my mail application and running Access 2003.

Can anyone please let me know why I still have problem with this code in the Data Access Page? If I forget any semi-colon or period or brackets, please post them as well. Thank you for your help.
 
What error message are you receiving?

A problem I ran into was that not everyone in our organization was running on the same operating system and some did not have outlook installed. Note that Windows XP, 2000, 2003 use CDO and Windows NT, 95, 98 use CDONTS. Consequently, I issue the email command server side (on our intranet server (which is Windows 2003)). I do this using xmlHTTP. My vbscript posts a message to an asp page (via xmlHTTP) who in turn issues the email command. Note that the asp page is not shown, rather it behaves as if I called a procedure within my vbscript. That is, no asp page is displayed and my vbscript waits until the asp page is finished. Now I don't have to worry if a user as outlook installed or if they have CDO installed or CDONTS.

In your case, if outlook is installed on your server, then call an asp page the emails using outlook. Then you don't have to worry whether or not the user as outlook installed.
 
Good afternoon,

The error that I received:

********************
Line: 200
Character: 1
Error: Syntax Error
Code: 0
URL: accdp//9056884/

Do you want to continue running scripts on this page?

****************

When I went to the Script editor and count the line, it starts with the line that I posted:

cdonst olMailItem = 0 (this is my line # 200. The first character should be "c" in the const ?)

**************************
When I changed it to: CDO

CDO olMailItem = 0 -- it generated another error.

Internet Explorer Script Error.
An Error has occurred in the script on this page

Line: 200
Char: 5
Error: Expected ';'
Code: 0
URL: accdp//9065848/

Do you want to continue running scripts on this page

********************
I do appreciate your assistant in this matter.


 
Don't you have javascript code mixed with VBScript code ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Good morning,

I would like to inform you that I downloaded the development version of Outlook Redemption (3rd Party Software) and it worked really well. The Object Model Guard does not pop-up anymore. Mr. Dmitry Streblechenko was kindly enough to send the codes that I would like to share with everyone.

When I created a button in the DAP, the email could be sent a OK.

This code will work when the Redemption is loaded on the machine. Otherwise, the error will be generated.

I created a button in the DAP and embedded with this code.

Function SendEmail()
const olMailItem = 0
dim SafeItem, oItem
set OutlookApplication = CreateObject("Outlook.Application”)
set NS = OutlookApplication.GetNamespace(“MAPI”)
NS.Logon
set SafeItem = CreateObject("Redemption.SafeMailItem")
set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an instance of Redemption.SafeMailItem
set oItem = OutlookApplication.CreateItem(0) 'Create a new message
SafeItem.Item = oItem 'Set Item property
SafeItem.Recipients.Add "Mymail@mymail.com; myanothermail@mymail.com"
SafeItem.Recipients.ResolveAll
SafeItem.Subject = "The new record has been added."
SafeItem.Body = ("The Request Has Been Added to the Database.")
SafeItem.Send

End Function

************************************************************

I would like to ask the board regarding one small enhancement on this code. I have a field name on the Data Access Page called "ProjectName". On the Element Properties, the ID is ProjectName3.

How can I integrate this ProjectName to my subject header? The current subject is: The new Record has been added.

If I have added a new project name called, "Colorado Journey", what do I need to do to modify the current codes to have the subject (heading) stated: "The new Record has been added. - Colorado Journey"? In this case, the email received in the inbox will have different subject names. Otherwise, I might receive 10+ with the same subject names. At least, I can prioritize it from Outlook.


I tried everywhere including put a DIM statement like:

dim SafeItem, oItem , vProject
....
....
vProject = ProjectName3
...
...
SafeItem.Subject = "The new record has been added." & ProjectName3
...
...

The email subject that I received was -> "The new record has been added - [Object]

I might miss a quotation or parenthesis or period somewhere. I am not familiar with VB Scripts. However, the enhancement on this matter will be greately appreciated. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top