+ Reply to Thread
Results 1 to 4 of 4

Auto emailing in the BCC column

Hybrid View

  1. #1
    Registered User
    Join Date
    09-18-2012
    Location
    oxford, uk
    MS-Off Ver
    Excel 2010
    Posts
    9

    Auto emailing in the BCC column

    Dear All,

    A bit stuck. I have created a workbook that searches for a list of operators dependant on search criteria.
    Then emails them a range that we edit.

    The problem comes when the email sent needs to be in a different format.
    I need help editing the macro so all the email addresses that come up in the search fill the BCC list in 1 email instead of 1 email per address.

    I can then .Display the email and put the more complicated body in manually and only have to send it once to everyone.

    Sub Email()
        Dim OutApp As Outlook.Application
        Dim OutMail As Outlook.MailItem
        Dim cell As Range
        For Each cell In Range("L4:L23")
            strbody = strbody & cell.Value & vbNewLine
        Next
        
        Application.ScreenUpdating = False
        Set OutApp = CreateObject("Outlook.Application")
    
        On Error GoTo cleanup
        For Each cell In Columns("D").Cells.SpecialCells(xlCellTypeConstants)
            If cell.Value Like "?*@?*.?*" And _
               LCase(Cells(cell.Row, "E").Value) = "yes" Then
    
                Set OutMail = OutApp.CreateItem(0)
                On Error Resume Next
                With OutMail
                    .To = cell.Value
                    .BCC = ""
                    .Subject = "Quotation Request"
                    .Body = "Dear " & Cells(cell.Row, "B").Value & vbNewLine & strbody
                    .SendUsingAccount = OutApp.Session.Accounts.Item(3)
                    .Display  'Or use Display
                End With
                On Error GoTo 0
                Set OutMail = Nothing
            End If
        Next cell
    
    cleanup:
        Set OutApp = Nothing
        Application.ScreenUpdating = True
    End Sub

    I have attached the file.
    Any help is appreciated

    Tom
    Attached Files Attached Files

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,311

    Re: Auto emailing in the BCC column

    Try:

    Sub sEmail()
        Dim OutApp
        Dim OutMail
        Dim cell As Range
        Dim sbcc As String
        For Each cell In Range("L4:L23")
            strbody = strbody & cell.Value & vbNewLine
        Next
        
        Application.ScreenUpdating = False
        Set OutApp = CreateObject("Outlook.Application")
    
        On Error GoTo cleanup
        For Each cell In Columns("D").Cells.SpecialCells(xlCellTypeConstants)
            If cell.Value Like "?*@?*.?*" _
            And LCase(Cells(cell.Row, "E").Value) = "yes" _
            Then
                sbcc = sbcc & cell.Value & ";"
            End If
        Next cell
    
        If sbcc <> "" Then
            Set OutMail = OutApp.CreateItem(0)
            On Error Resume Next
            With OutMail
                .To = ""
                .BCC = sbcc
                .Subject = "Quotation Request"
                .Body = "Dear " & Cells(cell.Row, "B").Value & vbNewLine & strbody
                .SendUsingAccount = OutApp.Session.Accounts.Item(3)
                .Display  'Or use Display
            End With
            On Error GoTo 0
            Set OutMail = Nothing
        End If
    
    cleanup:
        Set OutApp = Nothing
        Application.ScreenUpdating = True
    End Sub

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    09-18-2012
    Location
    oxford, uk
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Auto emailing in the BCC column

    TMShucks,

    Thats brilliant,

    thank you
    Tom

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,311

    Re: Auto emailing in the BCC column

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1