Hey,
I'm using Access 2007. I have a code to open a new message in outlook 2007.
Im tring to pull values from a query that contains email addresses. I figured I would use a DO...LOOP function to pull those values individually and add them to the "To" field in outlook. The column is called "EmailId" and the query is called "Email". I figure that the code should be in this format:
How can I go about this?
If anymore information is needed or unclear, let me know
Thank you
I'm using Access 2007. I have a code to open a new message in outlook 2007.
Code:
Private Sub btnEmail_Click()
Dim ol As Outlook.Application
Dim inbox As Folder
Dim msg As MailItem
Dim rcp As Recipient
Set ol = CreateObject("outlook.application")
Set inbox = ol.Session.GetDefaultFolder(olFolderInbox)
Set msg = ol.CreateItem(olMailItem)
'for each record in the query
Set rcp = msg.Recipients.Add()
rcp.Type = olTo
'next
msg.Subject = ""
msg.Body = ""
msg.Display
End Sub
Code:
Do
'function to specify field/value in column of query
Set rcp = msg.Recipients.Add("SelectedValue")
rcp.Type = olTo
Exit Do
'function that moves focus to next field
Loop Until ("FieldValue) is null
If anymore information is needed or unclear, let me know
Thank you
Comment