mustafaqusay
New Member
- Joined
- Jun 22, 2015
- Messages
- 18
I have excel sheet with email addresses in Column B. I have put a macro to send emails from column B (separate email for each email address) but I need to add a code to make outlook send the emails from specific account because I have 2 accounts in my outlook. Below is the code I have . can you help please ?
VBA Code:
Sub SendEm()
Dim i As Integer, Mail_Object, Email_Subject, o As Variant, lr As Long
lr = Cells(Rows.Count, "B").End(xlUp).Row
Set Mail_Object = CreateObject("Outlook.Application")
For i = 2 To lr
With Mail_Object.CreateItem(o)
.Subject = Range("B1").Value
.To = Range("B" & i).Value
.Body = "Test"
'.Send
.display 'disable display and enable send to send automatically
End With
Next i
MsgBox "E-mail successfully sent", 64
Application.DisplayAlerts = False
Set Mail_Object = Nothing
End Sub