I can't use VBA to send emails to email boxes outside the company

Su Jian 1 Reputation point
2021-01-18T10:13:25.243+00:00

IF @FG.COM is my company e-mail,@OP.COM is my e-mail,i can use vba sent the email to my company e-mail,but i can't sent to my e-mail. help me

Code:
Sub sendBatchMail()
t = Timer

Dim rowCount, endRowNo
Dim objOutlook As New Outlook.Application
Dim objMail As MailItem
Dim sendIndex

endRowNo = ThisWorkbook.Sheets("Sheet1").[a65535].End(xlUp).Row

Set objOutlook = New Outlook.Application

ThisWorkbook.Sheets("Sheet1").Select

For rowCount = 2 To endRowNo

Set objMail = objOutlook.CreateItem(olMailItem)

subjectname = ThisWorkbook.Sheets("sheet1").Range("b" & rowCount)

bodyname = ThisWorkbook.Sheets("sheet1").Range("c" & rowCount)

attach_address = ThisWorkbook.Sheets("sheet1").Range("d" & rowCount)

With objMail
.To = Cells(rowCount, 1)
.Body = bodyname
.Subject = subjectname
.Send
End With
Set objMail = Nothing
Application.Wait (Now + TimeValue("0:00:1"))
Next
MsgBox "Done!" & Chr(10) & "Run time is " & Timer - t & "seconds"
End Sub

Developer technologies | Visual Basic for Applications
{count} votes

1 answer

Sort by: Most helpful
  1. Erin Ding-MSFT 4,476 Reputation points
    2021-01-19T01:59:10.997+00:00

    @Su Jian

    Tag “office-excel-itpro” focuses on general issues about Excel clients.
    Since your issue is more related to VBA code, I would remove the tag “office-excel-itpro”.
    Thanks for your understanding.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.