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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

verify that email is sent

Status
Not open for further replies.

anasazii

Programmer
Jun 19, 2001
59
US
Hello all!

I have a form that sends an email. Currently I am doing this using an Outlook object, and after building the email I use the ".display" command to show the email...

Does anyone know of any way to make sure that the email is then actually sent (i.e. 'Send' button is pressed)?

I know I can use the ".send" command, but I would really like to display the message in case the user wants to change anything.

I have tried using the ".submitted", but as soon as the email is sent, the object is cleared out...message is 'item has been moved or deleted'. I'm thinking if anything, this may be how I can test, but I don't know how...I've tried isEmpty, but that returns false.

Any suggestions would be appreciated!

Thanks,
Janel
 
Hi,

this is a quick and dirty way to make sure that the user presses the "Send" button:

On your form create an unbound text box.
On your send button's click event do this:
(Change UnboundTextBoxName to the name that Access supplies or whatever you call it)

Me!UnboundTextBoxName = 1

On the Form also create a button that will close the form (disable the "Close Button" by setting the forms Close button property to "No").

Now on your close button's "On Click" event do this

If Me!UnboundTextBoxName = 1 Then
DoCmd.close

Exit_close_Click:
Exit Sub

Err_close_Click:
MsgBox Err.Description
Resume Exit_close_Click
Else
MsgBox "You did not send the e-mail!"
Me!SendButtonName.SetFocus
End If

This should force the user to click the "Send" button,

jbehrne

 
I forgot to add this:

Set the unbound text boxes Visible value to "No"
On your form's "On Current" event paste in this code:

Me!UnboundTextBoxName = ""

That way if people repeatedly use this form each time they open it the unbound text box will default to Null

jbehrne
 
jbehrne,

On your send button's click event do this:
(Change UnboundTextBoxName to the name that Access supplies or whatever you call it)


good idea, but how??? I am creating an email that is sent in Outlook. How do I capture the event from Outlook? That is where I am stuck.

Thanks, Janel
 
Hi Janel,

I'm sorry, but I think I misunderstood you! I created that bit of code to fit the line you had written:

"Does anyone know of any way to make sure that the email is then actually sent (i.e. 'Send' button is pressed)?"

But I was under the assumption that the user was pressing a button on an access form (my fault). I also don't know of a way to check to make sure that the e-mail was actually sent. However, I did run across a great page that has all sorts of information on sending e-mail through various means. You should find some system there that lets you double check to make sure the e-mail has been sent:


In some ASP pages I built I used the CDONTS method - which I believe is supported in Access. That way you don't need to be dependent on Outlook to send the e-mail. Try this code (from the above page):

********************************************************
If you are using NT or 2000 as an OS then you can use CDONTS. It uses the SMTP Service to send mail directly. However the SMTP service must be running on the machine and the machien must have internet access. You add a reference to Microsoft CDO for NTS 1.2 Library in Access.:

Dim oEMail As New CDONTS.EMail

EMail.From "anyname@anydomain.com"
EMail.To "youremail@yourdomain.com"
EMail.BodyFormat = CdoBodyFormatText
EMail.Body = "Insert some useful text here"
EMail.Importance = CdoHigh
EMail.AttachFile "C:\filename.txt"
EMail.Send

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

It should be a snap to create an error msgbox if the CDONTS fails to work to alert the user that the e-mail wasn't sent.

HTH,

jbehrne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top