|
NetMail - Simple program for sending mail from a batch file |
Imports System.Net.Mail Module Module1 Sub Main() Dim strRecipient As String = " " Dim strSubject As String = " " Try Dim a_strArgs() As String Dim i As Integer Dim j As Integer Dim objSmtpClient As New SmtpClient a_strArgs = Split(Command$, " ") If a_strArgs(0) = "" Then Console.WriteLine("Usage: netmail recipient@somewhere.com blah blah blah") Exit Sub Else strRecipient = a_strArgs(0) strSubject = "" For i = 1 To UBound(a_strArgs) strSubject = strSubject & a_strArgs(i) & " " Next End If objSmtpClient.Host = "myhost" objSmtpClient.Send("donotreply@somewhere.co.uk",strRecipient, strSubject, "from NetMail") Console.WriteLine("Message sent to " & strRecipient & " - " & Now()) Catch ex As Exception Console.WriteLine(ex.Message) Console.WriteLine(strRecipient) Console.WriteLine(strSubject) End Try End Sub End Module |