Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > TechHelp > Directory > Access > Send Email < Multi-Field Find | Import Excel >
Back to Send Email    Comments List
Upload Images   @Reply   Bookmark    Link   Email  
Multiple email addresses BCC
Jeff Bartuch 
      
2 years ago
Hello

I have watched the video. LOVE IT!!! I do have a question and request for code.

I would like Access to loop through selected records in a continuous form and instead of sending multiple emails, put all of the selected email addresses in the BCC field in one email so the user can send one email to multiple people. I hope you can help me solve my dilemma.

Thanks in advance Jeff
Alex Hedley  @Reply  
            
2 years ago
Could loop the recordset and just append it to a string separated by ';', then just set that to the SendTo property you want.
Jeff Bartuch OP  @Reply  
      
2 years ago
Thank you Alex. I'm by no means an expert. Does the code I have below look like it will do what I'm asking? Also can you please give me an example to put all of the email addresses in one BCC string? That way one email can be sent.


Private Sub EmailAgentBTN_Click()
    Dim db As Database
    Dim rs As Recordset
    Dim Msg As String, Subject As String
    Dim Counter As Long
    Dim BCC As String

    If MsgBox("Are you sure?", vbQuestion + vbYesNoCancel, "Send Email Confirmation") <> vbYes Then Exit Sub
    
    Set db = CurrentDb
   'Set rs = db.OpenRecordset("SELECT * FROM OutageQ")
    Set rs = Me.RecordsetClone - **** I READ SOMEWHERE THIS WILL USE THE SAME RECORD SET AS THE FORM THE EMAIL BUTTON IS LOCATED.
    Counter = 0

    While Not rs.EOF
        
     Msg = "Dear [Fname]" & ",<P>" & _
          "The following technical problem has been resolved:" & "<P>" & _
          "Problem:  " & BodyProblem & "<P>" & _
          "Thank you for your patience" & "<P>" & _
          "Sincerely," & "<P>" & _
          "<br>" & _
          "Signature"

          BCC={NEED CODE EXAMPLE} 'I already added an optional BCC to the global email module.

          Subject = "Problem Resolved - " & [IssueDescription] & " / Ticket # " & rs![Ticket Number]
          Status "Sending to " & rs![UserEmail] & "..."
          SendEmail Msg, rs![UserEmail], Subject, BCC, True

          Counter = Counter + 1
          rs.MoveNext
    Wend
    Set rs = Nothing
    Set db = Nothing
    MsgBox "Done! Sent " & Counter & " emails."
    
End Sub
Jeff Bartuch OP  @Reply  
      
2 years ago
Well I think I figured the loop part out on my own. Is there a way to use VBA to select a signature in Outlook? How can I specify the font size for the body text?
Kevin Robertson  @Reply  
           
2 years ago
You could use the MailItem.Signature property. This property returns or sets a String value that represents the name of the signature to use for the mail item.

Example:
Dim objOutlook As Outlook.Application
Dim objMail As Outlook.MailItem
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(olMailItem)
objMail.Signature = "Your signature name"
objMail.Display


To set the Font Size of the Body, you can use something like this:

objMail.HTMLBody = "This is the body text."
Jeff Bartuch OP  @Reply  
      
2 years ago
Thank you Kevin. Is there more to the don't size? objMail.HTMLBody.....?
Jeff Bartuch OP  @Reply  
      
2 years ago
Sorry. Font size?
Kevin Robertson  @Reply  
           
2 years ago
Sorry. Didn't print the entire code. Here's a screenshot.
Kevin Robertson  @Reply  
           
2 years ago

Jeff Bartuch OP  @Reply  
      
2 years ago
Thanks I'll give it a try.
Jeff Bartuch OP  @Reply  
      
2 years ago
I'm not getting that to work..... Any help would be greatly appreaciated.

''''''''''I have the following in a separate module
Public Sub SendEmail(MessageBody As String, RecipientEmail As String, Subject As String, _
     Optional CC As String, _
     Optional SendImmediately As Boolean)

    Dim O As Outlook.Application
    Dim M As Outlook.MailItem
    
    Set O = New Outlook.Application
    Set M = O.CreateItem(olMailItem)
    
    With M
        .BodyFormat = olFormatHTML
        .Signature = "Generic WITH PS"
        .HTMLBody = MessageBody
        .HTMLBody = "<font size=""3"">This is the body text.</font>"
        '.Body = Txt - if you use olFormatPlain
        .SentOnBehalfOfName = "XXXXSampleEmail.Sampleemail.com"
        '.Subject = "INC# - resolved"
        .To = RecipientEmail
        .CC = CC
        '.CC = "XXXXSampleEmail.Sampleemail.com"
        '.BCC = "[email protected]"
        .Subject = Subject
        If SendImmediately Then
            .Send
        Else
            .Display
        End If
    End With

    Set M = Nothing
    Set O = Nothing

End Sub



''''''''''I have this code on the form
Private Sub ResolvedEmailBTN_Click()
    
    Dim db As Database
    Dim rs As DAO.Recordset
    Dim Msg As String
    Dim Subject As String
    Dim CC As String
    
    If MsgBox("Are you sure?", vbQuestion + vbYesNoCancel, "Send Email Confirmation") <> vbYes Then Exit Sub
    
     Set db = CurrentDb
     Set rs = Forms!TicketSearchListF.Recordset

     ' Issue resolved email.
     Msg = "Dear Customer" & ",<P>" & _
          "The following technical problem has been resolved:" & "<P>" & _
          "Problem: ***ENTER PROBLEM DESCRIPTION HERE***" & "<P>" & _
          "Should you need any further assistance, please contact......." & "<P>" & _
          "Thank you for your patience" & "<P>" & _
          "Sincerely," & "<P>" & _
          CC = ""
          Subject = "Your issue has been resolved."
          SendEmail Msg, rs![Email Contact Info], Subject, CC, False
          

    Set rs = Nothing
    Set db = Nothing
    
End Sub
Kevin Robertson  @Reply  
           
2 years ago
I would put the code to change the Font Size in the actual Text String for the Message Body as in my screenshot below.
Kevin Robertson  @Reply  
           
2 years ago

Jeff Bartuch OP  @Reply  
      
2 years ago
Thank you again Kevin. That worked. Thank you for the example. Getting back to the signature. When I add the .Signature back in, I get and error "Object doesn't support this property or method". Code is shown above.
Jeff Bartuch OP  @Reply  
      
2 years ago

Kevin Robertson  @Reply  
           
2 years ago
Insert this code into the appropriate place in the SendEmail() Sub Routine in your Global Module.

'Declare a variable to store the signature.
Dim Signature As String

'Add before .BodyFormat = olFormatHTML
'This will show the email with the default signature
.Display

'This will store the signature in a variable
Signature = .HTMLBody

'Add after .BodyFormat = olFormatHTML
'This will combine your message with the signature
.HTMLBody = MessageBody & Signature
Jeff Bartuch OP  @Reply  
      
2 years ago
Kevin thank you. I think that worked, but not like I thought it would. I was trying to add a signature to the email as though I am selecting the signature from the message tab in Outlook. The code you gave me adds text where the signature would ordinarily go. I appreciate you. If can think of a way to add an Outlook signature please let me know.
Alex Hedley  @Reply  
            
2 years ago
%USERPROFILE%\Application Data\Microsoft\Signatures
Alex Hedley  @Reply  
            
2 years ago
Jeff Bartuch OP  @Reply  
      
2 years ago
You guys are the best. Thank you!

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Send Email.
 

 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2025 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/23/2025 2:00:22 PM. PLT: 2s