Trying to send email from Excel using VBA - it worked before (few months ago) but not now. Any ideas at all please? Keeps bugging on the .Send near the bottom. Thanks!

Anonymous
2025-04-04T16:42:57+00:00

' Set email properties

    With OutMail 

        ' Set the email address from correct Column 

        .To = ws.Cells(i, "U").Value 

        ' Set the subject 

        .Subject = "blah blah blah " 

        ' Create the email body with the requested information 

        .Body = "Dear " & ws.Cells(i, "B").Value & " " & ws.Cells(i, "D").Value & "," & vbNewLine & vbNewLine & \_ 

                "We are writing to acknowledge your wait of " & ws.Cells(i, "BY").Value & " weeks since your assessment with our service. " & vbNewLine & vbNewLine & \_ 

                "blah blah blah. " & vbNewLine & vbNewLine & \_ 

                "blah blah blah" & vbNewLine & vbNewLine & \_ 

                "1 blah blah blah" & vbNewLine & vbNewLine & \_ 

                "     Yes or No" & vbNewLine & vbNewLine & \_ 

                "If yes, please continue. If no, please end here and send your email. Thank you." & vbNewLine & vbNewLine & \_ 

                "2  blah blah blah " & vbNewLine & vbNewLine & \_ 

                "     Face to Face or Virtual" & vbNewLine & vbNewLine & \_ 

                "3  blah blah blah" & vbNewLine & vbNewLine & \_ 

                "     I cannot attend at these times: " & vbNewLine & vbNewLine & \_ 

                "4  blah blah blah " & vbNewLine & vbNewLine & \_ 

                "     Your answer: " & vbNewLine & vbNewLine & \_ 

                "5  blah blah blah " & vbNewLine & vbNewLine & \_ 

                "     Yes or No" & vbNewLine & vbNewLine & \_ 

                "6  blah blah blah" & vbNewLine & vbNewLine & \_ 

                "     Yes or No" & vbNewLine & vbNewLine & \_ 

                "7   blah blah blah " & vbNewLine & vbNewLine & \_ 

                "     Yes or No" & vbNewLine & vbNewLine & \_ 

                "blah blah blah " & vbNewLine & \_ 

                "Thank you very much for your patience and your answers. " & vbNewLine & vbNewLine & \_ 

                "Yours sincerely, " & vbNewLine & vbNewLine & \_ 

                "blah blah blah. " 

        ' Send the email 

        .Send 

    End With 

    ' Release the email object 

    Set OutMail = Nothing 

Next i 

' Release the Outlook application object 

Set OutApp = Nothing 

End Sub

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2025-04-04T17:21:02+00:00

    Option Explicit

    Sub SendEmail()

    Dim c As Range 
    
    Dim OutLookApp As Object 
    
    Dim OutLookMailItem As Object 
    
    Dim i As Integer 
    
    Dim xPath As String 
    
    xPath = Application.ActiveWorkbook.Path 
    
        For Each c In Range("U2:U" & Cells(Rows.Count, "U").End(xlUp).Row).Cells 
    
            Set OutLookApp = CreateObject("Outlook.application") 
    
            Set OutLookMailItem = OutLookApp.CreateItem(0) 
    
            With OutLookMailItem 
    
                    .To = c.Value 
    
                    .CC = "Your CC here" 
    
                    .BCC = "test" 
    
                    .Subject = "Your Subject here" 
    
                    .HTMLBody = "Your Body content here" 
    
                    .Display 
    
                    '.Send 
    
            End With 
    
        Next c 
    

    End Sub

    Download workbook : https://secure.internxt.com/d/sh/file/b93c8587-814a-4ba2-905e-a6e00065f5a7/6e36bb489e1087791891ef0dd2f7791e37bcc3bf37827c4dda1d808d0ee77b50

    Was this answer helpful?

    0 comments No comments