2012年vb中的电子邮件通知 [英] Email notification in vb 2012

查看:81
本文介绍了2012年vb中的电子邮件通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...我尝试使用通知按钮发送电子邮件通知。通知按钮是datagridviewtextboxcolumn13.Below是编码。问题出在message.To.Add ....请指教?谢谢。



私有子DataGridView1_CellContentClick(发件人为对象,e为DataGridViewCellEventArgs)处理DataGridView1.CellContentClick

message.From =新邮件地址(EmailTextBox1 .Text)

message.To.Add(DataGridViewTextBoxColumn13.ValueMember)

message.Priority = MailPriority.Normal

'smtp客户端设置

smtp.EnableSsl = True

smtp.Port = 587

smtp.Host =smtp.office365.com

smtp.Credentials = New Net.NetworkCredential(EmailTextBox1.Text,PasswordTextBox.Text)

smtp.Send(消息)

MsgBox(消息已发送)

End Sub

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

推荐答案

如果列DataGridViewTextBoxColumn13具有电子邮件地址,并且您希望在该特定列的单元格内容的单击事件上发送邮件[列的所有单元格DataGridViewTextBoxColumn13。将代码重写为 -



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 -

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


这篇关于2012年vb中的电子邮件通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆