简体   繁体   中英

Add Bcc addresses from a column of a datagridview

I'm creating a program that reads a column of a datagridview that contains email addresses and inserts them as Bcc.

I would like to write multiple email addresses in the Bcc.

I can enter one email address.

Mail.Bcc.Add(New MailAddress(Form10.DataGridView1.Rows(3). Cells(4). Value))

I would like to take all the column 4 of my datagridview.

Assuming you mean that you have multiple email addresses in the cell, presumably separated by some form of delimiter, then you can achieve what you want with code similar to this:

Dim MyEmailAddresses() As String, EmailAddress As String

MyEmailAddresses = Split(Form10.DataGridView1.Rows(3).Cells(4).Value, ",")

For Each EmailAddress In MyEmailAddresses
    Mail.Bcc.Add(New MailAddress(EmailAddress)
Next EmailAddress  

In this case, I have assumed that your email addresses are comma separated. If you use a different delimiter, simply replace "," with whatever delimiter you are using.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM