General discussion


Send Email from excel list using VB


i am building a macro for the companie i work for, I'm just starting to learn programming in school. the MAcro is supposed to read a list of emails in excel and generate and send an email. so far this is the code that i have.

Dim xlwkbk As Excel.Workbook ' excel workbook object
Dim olApp As Outlook.Application
Dim olmail As MailItem
Dim row As Long
Dim olMailItem
Dim MailId As String
Dim Name As String
Dim Details As String
Dim subject As String
Dim i As Integer
Dim n As Integer

n = 0
i = 0

MailId = xlwkbk.Sheets(1).Cells(i, 1)
Name = xlwkbk.Sheets(1).Cells(n, 2)

If wkbk.Cells. Is Not Empty Then
With olmail
.To = MailId
.subject = "Thank you for e-mail"
.Body = "dear <name>, & vbNewLine &_"
.Body = .Body & " Thank you "
End With
End If
n = n + 1
i = i + 1
end sub

i am getting a run time error.

please let me know if it is correct.
the emails are in colum A, ans starts at row 1. the names are in colum B, also start at row 1.

i am trying to have excell grab the email address generate the email, add the subject line, in the body at the begining, i am trying to add the Name from Colum B, plus some other txt i haven't added yet.

I'm a beginner your help would be greatly appreciated thank you.

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Back to Software Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums