Thread: Help with VBA
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Maury Markowitz[_2_] Maury Markowitz[_2_] is offline
external usenet poster
 
Posts: 119
Default Help with VBA

Try this method instead. It calls Outlook (change to Express if that's
what you use) using COM and thus gives you better control over the
process. Look for the line "someone.Type", which sets whether or not
it's a to, cc or bcc. No need to convert to HTML or anything like
that.

For r = 2 To 5
Email = Cells(r, 2)
if isEmpty(Email) then GoTo TRYNEXTROW ' ALWAYS do this!

Set outlookMsg = CreateObject("Outlook.Application").CreateItem(0)
' you can test here if it worked, but this normally throws errors if
it didn't

With outlookMsg
' add the addresses
Set someone = .Recipients.Add(email)
someone.Type = 1 ' 1="to", cc and bcc can also be made
someone.Resolve
' add more addresses here

' it's not a bad idea to test whether someone.Resolved is not null
' but I've never seen this happen when you use internet addresses

' title it and add the body
.Subject = Subj
.Body = Msg

' save and send!
.Save
.Send
End With
' all done, trash the object
Set outlookMsg = Nothing

TRYNEXTROW:
Next r