Emailing a Post form

G

Guest

I have created a custom form using the Post form. On the form, users will
select a recipient. I want that recipient to receive an email when the form
is posted. I have the following code. How do I get it to email the selected
recipient? I don't want to hard-code an email address in the code because
the recipient will vary.

Function Item_Write()
Set newItem = Application.CreateItem(0)
With newItem
..To = ???
..Subject = "New On-Site Visit Report"
..Body = "There is a new On-Site Visit Report for you to view."
..Send
End With
End Function
 
G

Guest

Did you want to present the user with the Address Book dialog to select a
Recipient? If so, you can't do this with the Outlook Object Model. You'll
have to use CDO - see the Session.AddressBook method.
 
G

Guest

There's only 2 or 3 choices to choose from so it doesn't need to be the
address book. It could be a Combo Box.

I've tried the following but I get "Object Required" when I post the form.

..To = ComboBox1.text
 
G

Guest

If you need to refer to a control value or a custom property value in an
Outlook form, you have to use different syntax.

For a control value:

myVar = Item.GetInspector.ModifiedFormPages("P.1").Controls("ComboBox1").Value

For a custom field (if you bound your control to a field, use this approach
instead):

myVar = Item.UserProperties("MyFieldName").Value

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/
 

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