ericaindallas
New Member
- Joined
- Aug 20, 2009
- Messages
- 45
My goal is to create a macro in Excel to produce an email in Outlook to all the email addresses listed in column I in one email in the "To:" field.
What I've accomplished in the following VBA is that it creates a separate email for each email address listed in column I.
How do I create just one email for the list of email addresses in column I?
Typing in the email addresses within the VBA is not an option. The list of email addresses change with another macro.
Thank you in advance.
-Erica
Sub SendEmail()
Dim OutlookApp As Outlook.Application
Dim MItem As Outlook.MailItem
Dim cell As Range
Dim Subj As String
Dim EmailAddr As String
Dim Recipient As String
Dim Msg As String
'Create Outlook object
Set OutlookApp = New Outlook.Application
'Loop through the rows
For Each cell In Columns("I").Cells.SpecialCells(xlCellTypeVisible)
If cell.Value Like "*@*" Then
'Get the data
Subj = "This is the Subject Field"
Recipient = cell.Offset(0, -1).Value
EmailAddr = cell.Value
'Compose Message
Msg = Recipient & vbCrLf
Msg = Msg & "Please review the following message."
'Create Mail Item and view before sending
Set MItem = OutlookApp.CreateItem(olMailItem)
With MItem
.To = EmailAddr
.Subject = Subj
.Body = Msg
.Display
End With
End If
Next
End Sub
What I've accomplished in the following VBA is that it creates a separate email for each email address listed in column I.
How do I create just one email for the list of email addresses in column I?
Typing in the email addresses within the VBA is not an option. The list of email addresses change with another macro.
Thank you in advance.
-Erica
Sub SendEmail()
Dim OutlookApp As Outlook.Application
Dim MItem As Outlook.MailItem
Dim cell As Range
Dim Subj As String
Dim EmailAddr As String
Dim Recipient As String
Dim Msg As String
'Create Outlook object
Set OutlookApp = New Outlook.Application
'Loop through the rows
For Each cell In Columns("I").Cells.SpecialCells(xlCellTypeVisible)
If cell.Value Like "*@*" Then
'Get the data
Subj = "This is the Subject Field"
Recipient = cell.Offset(0, -1).Value
EmailAddr = cell.Value
'Compose Message
Msg = Recipient & vbCrLf
Msg = Msg & "Please review the following message."
'Create Mail Item and view before sending
Set MItem = OutlookApp.CreateItem(olMailItem)
With MItem
.To = EmailAddr
.Subject = Subj
.Body = Msg
.Display
End With
End If
Next
End Sub