使用标题发送邮件并保存在用户的已发送邮件项目VB.NET中

时间:2017-11-16 14:57:29

标签: vb.net email smtpclient

我使用此代码使用SMTP发送电子邮件

  Dim clnt As New System.Net.Mail.SmtpClient
            clnt.UseDefaultCredentials = False
            clnt = New System.Net.Mail.SmtpClient(gate)
            Dim auth_info As System.Net.NetworkCredential = New System.Net.NetworkCredential(toAddress, pass)
            '// MESSAGE SETUP
            Dim msg As New System.Net.Mail.MailMessage(fromAddress, toAddress)


            If msg.To.Count = 0 Then Return False

            msg.CC.Clear()
            '// SEND A COPY TO SENDER
            'msg.Bcc.Add(auth_info.UserName)
            msg.Bcc.Add(fromAddress)

            'msg.DeliveryNotificationOptions = Net.Mail.DeliveryNotificationOptions.OnFailure
            'msg.DeliveryNotificationOptions = Net.Mail.DeliveryNotificationOptions.OnSuccess
            msg.Headers.Add("Disposition-Notification-To", fromAddress)

            msg.Subject = subject

            msg.Body = msgbody
            msg.IsBodyHtml = True
            Dim serverBusy As Boolean = True
            While serverBusy
                Try
                    clnt.Send(msg)
                    serverBusy = False
                Catch
                    serverBusy = True
                End Try

            End While
  1. 使用此代码,电子邮件的副本将发送给发件人,因为 bcc属性,但在“传入文件夹”中。
  2. 由于header属性,我实现了接收器的通知 阅读邮件。一个对话框询问接收者是否需要 发件人被告知他阅读了电子邮件,如果他 按OK,然后通过新消息通知发件人。该 问题是,通过此实现,询问发件人 打开邮件副本时的相同对话框(密件抄送 属性)。

0 个答案:

没有答案