如何在vb.net 2008中发送邮件时显示进度条 [英] how to show progress bar when sending mail in vb.net 2008
本文介绍了如何在vb.net 2008中发送邮件时显示进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Windows应用程序。 Vb.net 2008
我有一个表格用gmail id和附件发送邮件
我是什么我正在做的是我将我的zip文件发送到gmail id,
现在我想在发送邮件时向用户显示进度条
发送邮件我想显示一个msg就像成功一样布尔,邮件发送与否
这里是我发送邮件的代码。
========
Windows App. Vb.net 2008
I have a form to send mail using gmail id with attachments
what i am doing is i am sending my zip file to gmail id ,
now i want to show a progress bar to user when sending mail and after
send mail i want to show a msg Like Success as boolean , mail send or not
here is my code to send mail.
========
Imports System.Net.Mail
Public Class FrmSendMail
Dim mail As New MailMessage()
Private Sub FrmSendMail_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.ProgressBar1.MarqueeAnimationSpeed = 0
txtsubj.Text = "Sending Data"
txtfrom.Text = "nagcm2brd@gmail.com"
txtto.Text = "nagcm1hyd@gmail.com"
Dim pwd As String
pwd = "ayub1234"
If InternetConnection() = False Then
MessageBox.Show("No internet connection!", "Connecting to Internet", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Btnclose_Click(sender, e)
Else
MessageBox.Show("Internet connection detected!", "Connecting to Internet", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
Private Sub sendml()
Dim SmtpServer As New SmtpClient()
SmtpServer.Credentials = New Net.NetworkCredential("nagcm2brd@gmail.com", "ayub1234")
SmtpServer.Port = 587
SmtpServer.Host = "smtp.gmail.com"
SmtpServer.EnableSsl = True
mail = New MailMessage()
Dim addr() As String = txtto.Text.Split(",")
Try
mail.From = New MailAddress("nagcm2brd@gmail.com", "Baroda Data", System.Text.Encoding.UTF8)
Dim i As Byte
For i = 0 To addr.Length - 1
mail.To.Add(addr(i))
Next
mail.Subject = txtsubj.Text
mail.Body = txtmsg.Text
If ListBox1.Items.Count <> 0 Then
For i = 0 To ListBox1.Items.Count - 1
mail.Attachments.Add(New Attachment(ListBox1.Items.Item(i)))
Next
End If
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
mail.ReplyTo = New MailAddress(txtto.Text)
SmtpServer.Send(mail)
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Private Sub BtnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSend.Click
sendml()
End Sub
End Class
========
任何帮助都将受到高度赞赏。
先谢谢。
========
Any Help will be highly appreciated.
Thanks in advance.
推荐答案
一个小的谷歌搜索导致这个 [ ^ ]。
a small google search leads to this[^].
InternetConnection()函数的方法在哪里?
Where is InternetConnection()funtion's method?
这篇关于如何在vb.net 2008中发送邮件时显示进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文