Open Outlook

thegooser

Registered User.
Local time
Today, 19:09
Joined
Aug 16, 2010
Messages
15
Ahhh...... I can't cope!

OK guys I need some help :)

So I have a nice simple database with a nice simple form. One of the fields on that form is an email address. I'd like a button that opens up a new outlook email and populates the to field. So if I press the button on the form the result would be a blank new email with the "to" already filled in with whatever email address is on the form.

An example is on the "Facilty" template built into access 2010.

However, I have not messed about with macros or VB or anything other than the basic functions on Access so I don't know how or where to put code.

Is it possible for some kind gent / lady to put idiot proof steps for me to stick this bit of code in?

thanks for all your help
 
Add a commadbutton to your form and then stop the wizard open the properties of the button and change the name to something like SendForApproval then click the Event tab and use the On Click Event then add the following code. You also need to add the Reference to use Outlook in the VBA screen so go to the Tools Menu and References then search down for Microsoft Outlook, tick the box and then close the Reference dialog box then add this code, change the to part to the field name on the form.

Sub sendForApproval()
'*************************************************
'VBA Code created by Trevor G November 2009
'Set the Reference to use Outlook, Tools Menu and References
'*************************************************
Dim olApp As Outlook.Application
Dim olMail As MailItem
Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)
With olMail

.To = putyour fieldnamehere
.Subject = "File"
.Body = "Please find the file attached"
'.Attachments.Add "M:\File Location and name.pdf"
.Display 'or use .Send once you have it working

End With
Set olMail = Nothing
Set olApp = Nothing
End Sub
 

Users who are viewing this thread

Back
Top Bottom