Automatic Email From Custom Contact Form

G

Guest

I am building a custom contact form for my companies client database and what
I would like to have if possible is when the sales person initiates the
client contact form and saves it to a public folder an email would be
generated to me alerting me that a new contact has been filled out. Is this
possible?
 
S

Sue Mosher [MVP-Outlook]

You could put code in the form's Item_Write event handler to generate such a message.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

The basics would be:

Function Item_Write()
Set newItem = Application.CreateItem(0)
With newItem
.To = "(e-mail address removed)"
.Subject = "New contact"
.Body = "There is a new contact."
.Send
End With
End Function

Embellish to your heart's content.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

thanks so much!!!!

Sue Mosher said:
The basics would be:

Function Item_Write()
Set newItem = Application.CreateItem(0)
With newItem
.To = "(e-mail address removed)"
.Subject = "New contact"
.Body = "There is a new contact."
.Send
End With
End Function

Embellish to your heart's content.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Is there a way to put in the script so it only sends an email when the item
is created? Right now it is sending an email after any updating that is done
to the record... Thanks!
 
G

Guest

Also is there a way to program in the VB Script to note which contact the
addition is for within the email message so they know which one is new?
 
S

Sue Mosher [MVP-Outlook]

Is there a way to put in the script so it only sends an email when the item
is created?

Yes, but you're in danger of actually learning something about Outlook programming. Are you sure you want to do that? <g>

When a new item is created, it has a Size = 0. That means you can check the value of the Size property and act accordingly:

Function Item_Write()
If Item.Size = 0 Then
Set newItem = Application.CreateItem(0)
With newItem
.To = "(e-mail address removed)"
.Subject = "New contact"
.Body = "There is a new contact."
.Send
End With
End If
End Function
Also is there a way to program in the VB Script to note which contact the
addition is for within the email message so they know which one is new?

Yes, but it's time for you to do some homework of your own. All the pieces you need to do that are in the code above, except a couple that I'll give you. Here are the pieces you need to find and then put together to add your own code:

1) Outlook coding works largely with objects and properties of objects. There are many examples in the code above, where you read the property of one object and set the properties of another. Which object represents the current contact item?

2) Which object represents the new message to be sent?

3) Which property contains the name of the item? (HINT: It's the same for all types of items.)

4) Which property do you want to use to show the recipient the name of the new contact?

5) How do you put two pieces of text together?

I'll answer the last one for you -- with the ampersand & character, e.g. "red " & "balloon" would give you the string "red balloon."

See if you can figure it out, and then pat yourself on the back for learning something more than cut-and-paste about Outlook form scripting. Holler if you get stumped.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Thanks so much Sue.... I am already learning more than I thought I would but
I really am loving it. I will challenge myself and see if I can figure out
the second half. Thanks!
 
G

Guest

Ok after banging my head and trying every possible combination I am looking
for a little more help.
 
G

Guest

Ok after banging my head and trying every possible combination I am looking
for a little more help.
 
S

Sue Mosher [MVP-Outlook]

A little more help with what? Where specifically are you stumped?
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

specifically the last part trying to figure out which items I need to put in
the code for it to know which record has been updated when it sends out my
email. I have tried a combination of things but they either don't put the
record name in the email or I get an error when I try to open the form after
publishing it.

Also is there a way to program in the VB Script to note which contact the
 
S

Sue Mosher [MVP-Outlook]

Show us what you currently have. It's probably close enough that it needs just a tweak or two.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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