What Operating System are you using? If it is NT, 2K or XP then you could
use the CDONTS.NewMail object. Add a Reference to it first. Then in code:
Dim oMail As New CDONTS.NewMail
oMail.From = "(e-mail address removed)"
oMail.To = "(e-mail address removed)"
oMail.Cc = "(e-mail address removed)"
oMail.Bcc = "(e-mail address removed)"
oMail.Subject = "New Record Added"
oMail.Body = "Whatever message you want sent."
oMail.Send
Set oMail = Nothing
This won't pop any interface to the user - they will never know it happened!
message Hi Arvin,
Well I got it to work but I have one last question...How do I get it to
automatically send without having to hit the send button on the email? Is
there more code I should use to have this done? And also, can it be done
without having the email open up on my desktop?
:
With the AfterUpdate code that I posted, you won't need the Outlook code
because it uses SendObject. In the form's property sheet, click on the
Events tab, find the AfterUpdate event and double-click to bring up the
words:
[Event Procedure]
Then go to the ellipses (...) at the end of that line and click on it.
You'll get taken to the code stub where you can enter:
If Me.NewRecord = True Then
DoCmd.SendObject acSendNoObject, , [, to] , , [, subject][,
messagetext]
End If
Substitute your form variables for the [to], [subject], and
[messagetext]
parts between the commas. Make sure you leave the empty commas in place
for
the blank arguments.
A form variable will look like:
Me.[Name of your textbox here]
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
message The "AfterUpdate" code goes on the form event and the outlook code
goes
into
a module. Correct? Is there anything else that I need to do or will it
work
after I do that? Also, in the outlook code module do I need to specify
the
email address?
:
You can put it in the code module behind the form. The Outlook code
can
be
in the form module, or in a standard module.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
in
message Hi Arvin,
Thanks for the info. I do have one question though. Where would I
put
the
Outlook sample code that you referred to?
:
"Secret Squirrel" <
[email protected]>
wrote
in
message
Can anyone point me in the right direction as to how I would
create an
email
notification in Access2000? What I'm looking to do is have an
email
automatically generated when a new record is created. I want
to do
this so
it
can notify certain people when a new record has been created.
Any
help
would
be greatly appreciated.
You can use SendObject within Access (or any Office product)
Check
the
help
files out. You can also use Outlook. There is some sample code
on my
website:
http://www.datastrat.com/Code/OutlookEmail.txt
To fire off the code, just do something like (aircode):
Sub Form_AfterUpdate()
If Me.NewRecord = True Then
DoCmd.SendObject acSendNoObject, , [, to] , , [,
subject][,
messagetext]
End If
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access