Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi...i tried to send email notification using the notify button. The notify button is datagridviewtextboxcolumn13.Below is the coding.The problem is in the message.To.Add....Please advise? Thanks.

Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
message.From = New MailAddress(EmailTextBox1.Text)
message.To.Add(DataGridViewTextBoxColumn13.ValueMember)
message.Priority = MailPriority.Normal
'smtp clients settings
smtp.EnableSsl = True
smtp.Port = 587
smtp.Host ="smtp.office365.com"
smtp.Credentials = New Net.NetworkCredential(EmailTextBox1.Text, PasswordTextBox.Text)
smtp.Send(message)
MsgBox(message Is sent)
End Sub
Posted
Comments
Member 10738621 18-Jun-14 1:58am    
Thanks Sir...anyway when i tried the coding below there is an error message ie 'Rows' is not a member of 'System.Windows.Forms.DataGridViewComboBoxColumn'.Please advise and thanks a lot.

1 solution

if Column DataGridViewTextBoxColumn13 has email address and you want to send mail on click event of cell contents of that particular column [All cells of column DataGridViewTextBoxColumn13]. Rewrite the code as -

VB
Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
Dim ColIndex as Integer = ' Column Index of column DataGridViewTextBoxColumn13
message.From = New MailAddress(EmailTextBox1.Text)
message.To.Add(DataGridViewTextBoxColumn13.Rows(e.RowIndex).Cell(ColIndex).Value.ToString)
message.Priority = MailPriority.Normal
smtp clients settings
smtp.EnableSsl = True
smtp.Port = 587
smtp.Host ="smtp.office365.com"
smtp.Credentials = New Net.NetworkCredential(EmailTextBox1.Text, PasswordTextBox.Text)
smtp.Send(message)
MsgBox("message Is sent")
End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900