Emailing from Access?

Little_Man22

Registered User.
Local time
Today, 14:37
Joined
Jun 23, 2001
Messages
118
What I want to do is the following:

I have a form with a bunch of fields however, there are two important ones which I will discuss in regard to my question. One of the fields is called 'assignedto' and the other is named 'subject'. The 'assignedto' field is a combobox where the user has the option of selecting, among other names, 'RYAN'. When selected the form automatically tabs over to the next field 'subject' and gives the user the option of entering something...

What I want Access to do is automatically send an email to "***" when 'RYAN' is selected from the assignedto field. In this email I want Access to copy the contents of what was writen in the 'subject' field.

Is this possible? If so how?

Thanks,
Ryan.
 
It is possible to do this, and it is actually quite simple...In the references otpion of the tools menu in the vba window you need to select the microsoft outlook object library, this will allow you to control outlook from access...given that you want the email to be sent upon selection of a specific option, it would be best to add the code to accomplish this using the after update event of your combobox...using a simple if statement to determine if "RYAN" was the option chosen..Below is a sample of some code that i have used along with the declarartions neccessary to make it run...let me know if this works for you


'declare variables
These are the outlook objects that you will need
Dim olkapp As Outlook.Application
Dim olknamespace As Outlook.NameSpace
Dim objmailitem As Outlook.MailItem

You can insert your if statement at this point, if the condition is met you create and send the email item

'open outlook application
Set olkapp = New Outlook.Application
Set olknamespace = GetNamespace("MAPI")


'create a new mail item
Set objmailitem = olkapp.CreateItem(olMailItem)

'compose mail item and send
With objmailitem

.To = enter recipients email address surrounded by double quotes
.Recipients.ResolveAll
.Subject = add subject line
.Body = here is what you want the message to say…you can use the field names on the form to transfer the desired data.
.send this sends the message out

End With


'close outlook application
Set objmailitem = Nothing
Set olknamespace = Nothing
Set olkapp = Nothing
 
Is there a way to use this code to open a published Outlook form?
 
If I've understood your question....

.To = enter recipients email address surrounded by double quotes
.Recipients.ResolveAll
.Subject = add subject line
.Body = here is what you want the message to say…you can use the field names on the form to transfer the desired data.

.DISPLAY
 

Users who are viewing this thread

Back
Top Bottom