Hi! Thank you for considering to help me.
I am trying to create a simple Send Mail button which is located on my contacts form. When you click on it Outlook will open and the email address will already be populated and the subject will be populated. I have this code from a sample database which works in the sample but does not work when I incorporated it into my database.
Here is the module code basAutomateOutlook:
Here is the click event code cmdEmail:
Here are the references:
Visual Basic for Applications
Microsoft Outlook 14.0 Library
OLE Automation
Visual Basic for Application Extensibility 5.3
I am using Access 2010
The only thing additional I would like this button to do, currently it adds one email to the To, I can have up to 3 emails for my customers so I would like it to populate all 3 emails in the To Field.
If someone could please help me figure out what I need to change to make this work, I would appreciate it!
I am trying to create a simple Send Mail button which is located on my contacts form. When you click on it Outlook will open and the email address will already be populated and the subject will be populated. I have this code from a sample database which works in the sample but does not work when I incorporated it into my database.
Here is the module code basAutomateOutlook:
Code:
Public Sub SendEmail(varTo As Variant)
Dim mailItem As Outlook.mailItem
InitOutlook
Set mailItem = outlookApp.CreateItem(olMailItem)
mailItem.To = varTo & ""
mailItem.Subject = "Message for Access Contact"
mailItem.Display
Set mailItem = Nothing
CleanUp
End Sub
Here is the click event code cmdEmail:
Code:
Private Sub cmdEmail_Click()
Call SendEmail(Me.Email)
End Sub
Here are the references:
Visual Basic for Applications
Microsoft Outlook 14.0 Library
OLE Automation
Visual Basic for Application Extensibility 5.3
I am using Access 2010
The only thing additional I would like this button to do, currently it adds one email to the To, I can have up to 3 emails for my customers so I would like it to populate all 3 emails in the To Field.
If someone could please help me figure out what I need to change to make this work, I would appreciate it!