data access page email functionality

  • Thread starter Thread starter greg
  • Start date Start date
G

greg

I have an Access mdb which has a data access page that is used for
data entry. I want to allow the users to e-mail the completed data
entry form to themselves for reference. However, I’m stumped as to
how to do that.

I’ve tried the vbscript code (see below) in the data access page, and
although the vbscript works fine as a standalone vbs file, the code
does not send an email when the code is included in the data access
page.

Here’s the vbscript code:
'Sends an email to selected recipients.

Dim ToAddress
Dim MessageSubject
Dim MessageBody
Dim MessageAttachment

Dim ol, ns, newMail

Dim MyArray, i 'used for e-mailing to multiple recipients

'send the e-mail
ToAddress = "(e-mail address removed)"
MessageSubject = "Access Web Form Test"
' MessageBody = "Here's the message body."

Set ol = WScript.CreateObject("Outlook.Application")
Set ns = ol.getNamespace("MAPI")
ns.logon "","",true,false

'parse the e-mail addresses into separate recipients, and process
each recipient (one recipient at a time)
MyArray = Split(ToAddress, ";", -1, 1)

For i = 0 to UBound(MyArray)
Set newMail = ol.CreateItem(olMailItem)
newMail.Subject = MessageSubject
newMail.Body = MessageBody & vbCrLf

'validate the recipient
Set myRecipient = ns.CreateRecipient(MyArray(i))
myRecipient.Resolve
If Not myRecipient.Resolved Then
MsgBox "unknown recipient"
Else
newMail.Recipients.Add(myRecipient)
newMail.Send
End If
Next

Set ol = Nothing

Any help would be much appreciated. Thanks in advance.
 
I have an Access mdb which has a data access page that is used for
data entry. I want to allow the users to e-mail the completed data
entry form to themselves for reference. However, I’m stumped as to
how to do that.

I’ve tried the vbscript code (see below) in the data access page, and
although the vbscript works fine as a standalone vbs file, the code
does not send an email when the code is included in the data access
page.

Here’s the vbscript code:
'Sends an email to selected recipients.

Dim ToAddress
Dim MessageSubject
Dim MessageBody
Dim MessageAttachment

Dim ol, ns, newMail

Dim MyArray, i 'used for e-mailing to multiple recipients

'send the e-mail
ToAddress = "(e-mail address removed)"
MessageSubject = "Access Web Form Test"
' MessageBody = "Here's the message body."

Set ol = WScript.CreateObject("Outlook.Application")
Set ns = ol.getNamespace("MAPI")
ns.logon "","",true,false

'parse the e-mail addresses into separate recipients, and process
each recipient (one recipient at a time)
MyArray = Split(ToAddress, ";", -1, 1)

For i = 0 to UBound(MyArray)
Set newMail = ol.CreateItem(olMailItem)
newMail.Subject = MessageSubject
newMail.Body = MessageBody & vbCrLf

'validate the recipient
Set myRecipient = ns.CreateRecipient(MyArray(i))
myRecipient.Resolve
If Not myRecipient.Resolved Then
MsgBox "unknown recipient"
Else
newMail.Recipients.Add(myRecipient)
newMail.Send
End If
Next

Set ol = Nothing

Any help would be much appreciated. Thanks in advance.
 
Back
Top