Automatic E-mail

bopo

Member
Joined
Dec 10, 2006
Messages
13
Programming Experience
Beginner
Hi people

Well basically I want to send a e-mail when a button is clicked, the e-mail will contain the same information each time (no changes required) and only be sent to two people each time (to keep it simple)

Does anyone know the coding to do this?
 
Last edited:
or (just to ensure you still do at least some work)
VB.NET:
[FONT=Courier New]Imports System.Net.Mail 

Class SimpleMailer 

 Public Shared Function SendMail(ByVal to As String, ByVal reportName As String, ByVal message As String) As Boolean 
   Dim un As String = Environment.UserName 
   Dim mm As MailMessage = New MailMessage 
   mm.From = New MailAddress("apparently-from address", "apparently-from friend name e.g. Bill Smith") 
   mm.Sender = New MailAddress("really-from address", "sent on behalf of Bill Smith by MyApp.exe") 
   mm.To.Add(New MailAddress(to)) 
   mm.Subject = "Regarding " + reportName 
   mm.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(message, New System.Net.Mime.ContentType("text/plain"))) 
   Try 
     Dim server As SmtpClient = New SmtpClient("mailserver") 
     server.Credentials = New System.Net.NetworkCredential("user", "pass", "domain") 
     server.Send(mm) 
     Return True 
   Catch generatedExceptionVariable0 As Exception 
     Return False 
   End Try 
 End Function 
End Class[/FONT]
 
Back
Top