I would like to build a windows app or service that would read a .txt
file and than put the contents of that file in an email and send off
the email. WOuld that be very difficult?...how could this be done?
Hi,
Reading of text file can be done using WebClient's downloadstring
method if the file resides on remote host. If file is local, you can
use StreamReader.
You can send mail with attachments using System.Net.SmtpClient class.
A sample code would be:
' Instantiate SmtpClient Class
Dim emailClient As New SmtpClient("smtp.gmail.com")
' Instantiate MailMessage Class
Dim message As New MailMessage("from_here", "to_here", "subject_here",
"body_here")
message.Attachments.Add(New Attachment("attachment_path_here")
' Credentials here <optional>
' Set credentials using System.Net.NetworkCredential...
' .......
' Send mail
emailClient.Send(message)
Hope this helps,
Onur Güzel