Email Notification

G

Guest

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.
 
A

Arvin Meyer [MVP]

Secret Squirrel said:
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
 
G

Guest

Hi Arvin,
Thanks for the info. I do have one question though. Where would I put the
Outlook sample code that you referred to?

Arvin Meyer said:
Secret Squirrel said:
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
 
A

Arvin Meyer [MVP]

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

Secret Squirrel said:
Hi Arvin,
Thanks for the info. I do have one question though. Where would I put the
Outlook sample code that you referred to?

Arvin Meyer said:
Secret Squirrel said:
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
 
G

Guest

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?

Arvin Meyer said:
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

Secret Squirrel said:
Hi Arvin,
Thanks for the info. I do have one question though. Where would I put the
Outlook sample code that you referred to?

Arvin Meyer said:
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
 
A

Arvin Meyer [MVP]

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

Secret Squirrel said:
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?

Arvin Meyer said:
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

Secret Squirrel said:
Hi Arvin,
Thanks for the info. I do have one question though. Where would I put the
Outlook sample code that you referred to?

:

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
 
G

Guest

Can I just type in the email address I want to send this to in the "[to]"
part of this code or does it need to come from somewhere on the form?

Arvin Meyer said:
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

Secret Squirrel said:
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?

Arvin Meyer said:
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

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?

:

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
 
G

Guest

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?

Arvin Meyer said:
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

Secret Squirrel said:
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?

Arvin Meyer said:
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

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?

:

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
 
R

Ron Hinds

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!

Secret Squirrel said:
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?

Arvin Meyer said:
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

Secret Squirrel said:
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

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
 
G

Guest

I'm using WinXPpro. What is the reference called that I need to add? Where do
I put this additional code in my code? Do I put it first or last?

Ron Hinds said:
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!

Secret Squirrel said:
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?

Arvin Meyer said:
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

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?

:

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
 
R

Ron Hinds

It's called "Microsoft CDO for NTS 1.2 Library". If you have to Browse to
find it, it is called CDONTS.DLL and should be in the System32 folder. Put
the code right where you put the SendObject line (comment out the SendObject
line). XP may only have the newer version of this, called CDOSYS.DLL (2K has
both, NT only has CDONTS). It works in the same way, though.

Secret Squirrel said:
I'm using WinXPpro. What is the reference called that I need to add? Where do
I put this additional code in my code? Do I put it first or last?

Ron Hinds said:
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!

Secret Squirrel said:
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

"Secret Squirrel" <[email protected]>
wrote
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?

:


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
 
G

Guest

But I'm still using the "IF" statement in the code, correct?

Ron Hinds said:
It's called "Microsoft CDO for NTS 1.2 Library". If you have to Browse to
find it, it is called CDONTS.DLL and should be in the System32 folder. Put
the code right where you put the SendObject line (comment out the SendObject
line). XP may only have the newer version of this, called CDOSYS.DLL (2K has
both, NT only has CDONTS). It works in the same way, though.

Secret Squirrel said:
I'm using WinXPpro. What is the reference called that I need to add? Where do
I put this additional code in my code? Do I put it first or last?

Ron Hinds said:
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
 
G

Guest

Hi Ron,
I just tried to run the code but I keep getting a "user-defined type not
defined" error. I found the "CDOSYS.DLL in the system32 folder and added that
reference but I kept getting that error. Then I chose the "Microsoft CDO"
reference instead and I'm getting the same error message. Any idea what might
be wrong?

Ron Hinds said:
It's called "Microsoft CDO for NTS 1.2 Library". If you have to Browse to
find it, it is called CDONTS.DLL and should be in the System32 folder. Put
the code right where you put the SendObject line (comment out the SendObject
line). XP may only have the newer version of this, called CDOSYS.DLL (2K has
both, NT only has CDONTS). It works in the same way, though.

Secret Squirrel said:
I'm using WinXPpro. What is the reference called that I need to add? Where do
I put this additional code in my code? Do I put it first or last?

Ron Hinds said:
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
 
W

wang xiao dan

gik
Secret Squirrel said:
But I'm still using the "IF" statement in the code, correct?

Ron Hinds said:
It's called "Microsoft CDO for NTS 1.2 Library". If you have to Browse to
find it, it is called CDONTS.DLL and should be in the System32 folder. Put
the code right where you put the SendObject line (comment out the SendObject
line). XP may only have the newer version of this, called CDOSYS.DLL (2K has
both, NT only has CDONTS). It works in the same way, though.

Secret Squirrel said:
I'm using WinXPpro. What is the reference called that I need to add?
Where
do
I put this additional code in my code? Do I put it first or last?

:

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

"Secret Squirrel" <[email protected]>
wrote
in
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


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"
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
 
W

wang xiao dan

Secret Squirrel said:
But I'm still using the "IF" statement in the code, correct?

Ron Hinds said:
It's called "Microsoft CDO for NTS 1.2 Library". If you have to Browse to
find it, it is called CDONTS.DLL and should be in the System32 folder. Put
the code right where you put the SendObject line (comment out the SendObject
line). XP may only have the newer version of this, called CDOSYS.DLL (2K has
both, NT only has CDONTS). It works in the same way, though.

Secret Squirrel said:
I'm using WinXPpro. What is the reference called that I need to add?
Where
do
I put this additional code in my code? Do I put it first or last?

:

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

"Secret Squirrel" <[email protected]>
wrote
in
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


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"
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
 
R

Ron Hinds

The CDOSYS.DLL is the correct one. Since you are using it, the code will
need to be changed slightly:

Dim oMail As New CDO.Message

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.TextBody = "Whatever message you want sent."

oMail.Send

Set oMail = Nothing


Secret Squirrel said:
Hi Ron,
I just tried to run the code but I keep getting a "user-defined type not
defined" error. I found the "CDOSYS.DLL in the system32 folder and added that
reference but I kept getting that error. Then I chose the "Microsoft CDO"
reference instead and I'm getting the same error message. Any idea what might
be wrong?

Ron Hinds said:
It's called "Microsoft CDO for NTS 1.2 Library". If you have to Browse to
find it, it is called CDONTS.DLL and should be in the System32 folder. Put
the code right where you put the SendObject line (comment out the SendObject
line). XP may only have the newer version of this, called CDOSYS.DLL (2K has
both, NT only has CDONTS). It works in the same way, though.

Secret Squirrel said:
I'm using WinXPpro. What is the reference called that I need to add?
Where
do
I put this additional code in my code? Do I put it first or last?

:

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

"Secret Squirrel" <[email protected]>
wrote
in
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


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"
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
 
A

Arvin Meyer [MVP]

Using the SendObject method doesn't require any additional references. It is
a method that's part of all Office apps but doesn't have quite as many
methods as using either Outlook, or CDO. In any case, it can send without
opening (although I've never used it that way). The syntax is:


DoCmd.SendObject [objecttype][, objectname][, outputformat][, to][, cc][,
bcc][, subject][, messagetext][, editmessage][, templatefile]

If the editmessage arguement is set to False, the email will send without
opening, so the code would now look like:

If Me.NewRecord = True Then
DoCmd.SendObject acSendNoObject, , [, to] , , [, subject][, messagetext],
False
End If
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

Secret Squirrel said:
But I'm still using the "IF" statement in the code, correct?

Ron Hinds said:
It's called "Microsoft CDO for NTS 1.2 Library". If you have to Browse to
find it, it is called CDONTS.DLL and should be in the System32 folder. Put
the code right where you put the SendObject line (comment out the SendObject
line). XP may only have the newer version of this, called CDOSYS.DLL (2K has
both, NT only has CDONTS). It works in the same way, though.

Secret Squirrel said:
I'm using WinXPpro. What is the reference called that I need to add?
Where
do
I put this additional code in my code? Do I put it first or last?

:

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

"Secret Squirrel" <[email protected]>
wrote
in
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


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"
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top