电子邮件新图片而不是旧图片

时间:2015-02-04 01:46:11

标签: vb.net email

我希望我的程序在我选择的文件夹中创建新图像时,这里是用于发送文件夹中所有图像的工作代码

Dim attachment As System.Net.Mail.Attachment
Dim open as new FolderBrowserDialog
        Try
            Dim myPath As String = open.SelectedPath
            Dim files = Directory.GetFiles(myPath, "*.*", System.IO.SearchOption.AllDirectories)
            Dim mail As New MailMessage
            mail.Subject = ("Ip Camera Monitor Motion Email")
            mail.Body = ("Motion was detected")
            mail.To.Add(My.Settings.email)
            mail.From = New MailAddress("ipcameramonitor@gmail.com")
            For Each superfile As String In files
                ListBox1.Items.Add(superfile)
            Next
            For Each item In ListBox1.Items
                attachment = New System.Net.Mail.Attachment(item)
                mail.Attachments.Add(attachment)
            Next
            Dim SMTP As New SmtpClient("smtp.gmail.com")
            SMTP.EnableSsl = True
            SMTP.Credentials = New System.Net.NetworkCredential("ipcameramonitor", "password")
            SMTP.Port = "587"
            SMTP.Send(mail)
        Catch ex As Exception
        End Try
    End If
   End Sub

我尝试添加另一个列表框并将其项目包含旧图像,然后执行Listbox1.Items.Remove(Listbox2.Items)或让它尝试删除所选项目并继续选择它不起作用的每个项目我无法删除我的程序锁定的旧图像,而不是之前通过电子邮件发送它们。任何帮助表示赞赏。

0 个答案:

没有答案