Home > Mobile >  Mail.Bcc.Add more address
Mail.Bcc.Add more address

Time:11-18

Good morning I state I'm at the beginning regarding VBA programming, I'm creating a program that reads columns of a datagridview that contains email addresses and inserts them as Bcc (copy hidden knowledge) .

I can't enter more than 1 address

I would like to understand the syntax to write multiple email addresses in the bcc:

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

so I can only enter an email, I would like it to take all the column 4 of my datagridview.

CodePudding user response:

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.

CodePudding user response:

Good morning thanks for the reply, the addresses are in row (i) (where i is an integer variable, so there may be several rows) and in column 4, in each cell of column 4 there is an address to send a hidden email, they are not all put in one cell.

  • Related