I have used Hans SendMail ( i think it's Hans, apologies if not) a lot in recent years.
What i want to do is to send it to BCC and to TO.
What code do i need to do that?
SendMail
-
- 3StarLounger
- Posts: 390
- Joined: 26 Jan 2010, 16:02
- Location: Las Vegas, NV
Re: SendMail
Pat,
Here is an excerpt from a routine that I use to SendMail. Hans did help me with parts of it. Note that I use the Bcc field but not the To field.
I'm just guessing here but to send to the To Field, I would add within the With / End With set. strToaddresses would be a string containing the To addresses.
Hope this helps.
Here is an excerpt from a routine that I use to SendMail. Hans did help me with parts of it. Note that I use the Bcc field but not the To field.
Code: Select all
Set objOutlook = CreateObject("Outlook.Application", "localhost")
rstMembers.MoveFirst
Do While Not rstMembers.EOF
If Not IsNull(rstMembers!strE_MAIL) Then
strBcc = strBcc & rstMembers!strE_MAIL & ";"
lngCounter = lngCounter + 1
If lngCounter Mod 300 = 0 Then
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
.BCC = strBcc
.Subject = strSubject
.HTMLBody = strmsg
'.Send 'Will cause warning message
.Display
' MsgBox "Please click OK when the e-mail has been sent.", vbInformation
End With
strBcc = ""
End If
End If
rstMembers.MoveNext
Loop
Code: Select all
.To = strToaddresses
Hope this helps.
Carol W.
-
- Administrator
- Posts: 78676
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: SendMail
You can use any combination of To, CC and BCC addresses:
Simply leave the strings you don't need blank, or omit them altogether.
Code: Select all
Dim strTo As String
Dim strCC As String
Dim strBCC As String
...
...
strTo = ...
strCC = ...
strBCC = ...
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
.To = strTo
.CC = strCC
.BCC = strBCC
...
...
End With
Best wishes,
Hans
Hans