sending email from excel via outlook, send list

nmk34

New Member
Joined
Apr 12, 2022
Messages
45
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
i have a workbook that i send email to recipients by typing their email address like this:
oMail.To = " name1@gmail.com ; name2@gmail.com; name3@gmail.com" and it works fine. now there is a need to populate the list of emails in shee1 of the workbook, for example column AM2 thru AM20. has all email addresses.
how can I use the sheet1 column with [ oMail.To= ]?

Thanks
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi nmk34,

You could incorporate this into you existing code:

VBA Code:
Option Explicit
Sub Macro1()

    Dim rngCell As Range
    Dim strTo As String
    
    For Each rngCell In Sheets("Sheet1").Range("AM2:AM20")
        strTo = IIf(Len(strTo) = 0, rngCell, strTo & ";" & rngCell)
    Next rngCell
    
    oMail.To = strTo

End Sub

Regards,

Robert
 
Upvote 0
Hi nmk34,

You could incorporate this into you existing code:

VBA Code:
Option Explicit
Sub Macro1()

    Dim rngCell As Range
    Dim strTo As String
   
    For Each rngCell In Sheets("Sheet1").Range("AM2:AM20")
        strTo = IIf(Len(strTo) = 0, rngCell, strTo & ";" & rngCell)
    Next rngCell
   
    oMail.To = strTo

End Sub

Regards,

Robert
 
Upvote 0
Stro always =0. it will hang on .sendemail after the for loop. error message content, "we need to know to whome we should send this email, make sur you have at least one recipient"
 
Upvote 0
Not sure as it worked for me 🤔

Try stepping through the code to see why it’s not picking up the distribution list from the given range.
 
Upvote 0

Forum statistics

Threads
1,224,802
Messages
6,181,054
Members
453,014
Latest member
Chris258

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top