Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Sub email()
- 'import this Imports System.IO
- Dim Pathstore As String = String.Empty
- Dim Pathcode As String = String.Empty
- With New StreamReader("C:\VB Test\location.txt")
- Pathstore = .ReadLine()
- .Dispose()
- End With
- ' Are you sure this is the correct file ?
- With New StreamReader("C:\VB Test\rmmsiul.dll")
- Pathcode = .ReadLine()
- .Dispose()
- End With
- ' Capture the list of Attachment Files here, then use it twice below
- Dim Attachments() As String = Directory.GetFiles("C:\VB Test\Receipts")
- Dim e_mail As New Net.Mail.MailMessage()
- With e_mail
- .From = New Net.Mail.MailAddress("Do-Not-Reply@suncommobile.com")
- .Subject = String.Format("{0} Manual reciepts", Pathstore)
- .Body = String.Format("Here are the manual reciepts I created today.{0}{0}{0}Thank you,{0}{1}", Environment.NewLine, Pathstore)
- ' Since I don't know what Filter() returns, this is best guess to reproduce the same outcome
- For Each line As String In Filter(File.ReadAllLines("C:\VB Test\stores.txt"), Pathstore)
- Dim fields() As String = line.Split(",")
- .CC.Clear()
- .CC.Add(fields(4))
- .CC.Add(fields(2))
- .CC.Add(fields(6))
- Next
- For Each filepath In Attachments
- .Attachments.Add(New Net.Mail.Attachment(filepath))
- Next
- End With
- With New Net.Mail.SmtpClient
- .Host = "smtp.office365.com"
- .Credentials = New Net.NetworkCredential("Do-Not-Reply@suncommobile.com", Pathcode)
- .Port = 587
- .EnableSsl = True
- .Send(e_mail)
- End With
- ' Dispose the MailMessage to release the holds on the Attachment Files
- e_mail.Dispose()
- ' Delete the Attachment Files
- For Each filepath In Attachments
- File.Delete(filepath)
- Next
- MsgBox("E-mail Sent.")
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement