Solved

Not receiving message when bcc vba

Posted on 2008-10-09
2
530 Views
Last Modified: 2013-11-27
Hello experts,

I am trying to send email via VBA from Access.  Everything works find except for Bcc.  I am not getting the message on Bcc.  Please help.  Here is the code I am using.  Thank you.
Private Sub SendEmail(strEmailAdd As String, strFrom As String, strBody As String, _

                      strSubject As String, strCc As Variant, strBcc As Variant)

On Error GoTo errHandler
 

Dim objOutlook As Outlook.Application

Dim objOutlookMsg As Outlook.MailItem

Dim objOutlookRecip As Outlook.Recipient

Dim objOutlookAttach As Outlook.Attachment

Dim objOutlookFrom As Outlook.MailItem

Dim objOutlookInbox As Outlook.MAPIFolder
 

' Create the Outlook session.

Set objOutlook = CreateObject("Outlook.Application")
 

' Create the message.

Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
 

With objOutlookMsg
 

' Set sender

.SentOnBehalfOfName = strFrom
 

' Add the To recipient(s) to the message. This can be a variable or pulled form a table if desired.

Set objOutlookRecip = .Recipients.Add(strEmailAdd)

objOutlookRecip.Type = olTo
 

' Add the Cc recipient(s) to the message.

If Not ISNULL(strCc) Then

   .CC = strCc

End If
 

' Add the Bcc recipient(s) to the message.

If Not ISNULL(strBcc) Then

    .BCC = strBcc

End If
 
 

' Set the Subject, Body, and Importance of the message.

.Subject = strSubject

.HTMLBody = strBody

.Importance = olImportanceNormal  'Normal importance
 

' Resolve each Recipient's name.

        For Each objOutlookRecip In .Recipients

            objOutlookRecip.Resolve

        Next

        If Not .Recipients.ResolveAll Then

            For Each objOutlookRecip In .Recipients

                If Not objOutlookRecip.Resolved Then

                    MsgBox "Error on e-mail name " & objOutlookRecip & ". I will open the e-mail so you can correct it before you send it."

                End If

            Next

        .Display

        Else:

            .Save

            .Send

        End If

    End With

    

exitHere:

    Set objOutlook = Nothing

    Exit Sub
 

errHandler:

    Select Case Err

        Case Else

            MsgBox "Error Number: " & Err.Number & vbNewLine & "Description: " & Err.Description, vbCritical, "Error"

        GoTo exitHere

    End Select

End Sub

Open in new window

0
Comment
Question by:fcoit
2 Comments
 
LVL 16

Expert Comment

by:Chuck Wood
ID: 22682985
According to the Outlook help, the BCC property contains the display names only. The recipients collection should be used modify the BCC recipients.

Here is an example:

I hope that help you.

-Chuck
Public Sub TestBCC()

    Dim item As MailItem, rcp As Recipient

    Set item = Application.CreateItem(olMailItem)

    Set rcp = item.Recipients.Add("John Grande<jgrande@somewhere.com>")

    rcp.Type = olBCC

    item.Display

End Sub

Open in new window

0
 

Accepted Solution

by:
fcoit earned 0 total points
ID: 22683033
Hi Chuck,

Thank you for your response.  I think it is working now.  I using the same address for both the CC and BCC.  I changed that and it is working.  Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now