At our company, we use the corporate edition of McAfee VirusScan, which blocks TCP Port 25.
Here is a VB.NET workaround that I just devised. Still working on a way to prevent the command prompt NET.EXE windows from appearing:
Sub Main()
sendEMail()
Console.WriteLine(vbCrLf & "Press a key to exit.")
Console.ReadLine()
End Sub
Private Sub stopMcAfee()
Dim proc As Process
proc = Process.Start("NET.EXE", "STOP McAfeeFramework")
proc.WaitForExit()
proc = Process.Start("NET.EXE", "STOP McShield")
proc.WaitForExit()
proc = Process.Start("NET.EXE", "STOP McTaskManager")
proc.WaitForExit()
End Sub
Private Sub startMcAfee()
Dim proc As Process
proc = Process.Start("NET.EXE", "START McAfeeFramework")
proc.WaitForExit()
proc = Process.Start("NET.EXE", "START McShield")
proc.WaitForExit()
proc = Process.Start("NET.EXE", "START McTaskManager")
proc.WaitForExit()
End Sub
Private Sub sendEMail()
Dim mail As New MailMessage()
Dim from As String = "legitimate.account@someplace.com"
Dim subject As String = "Test Subject"
Dim body As String = _
"<html><body><h1>Test Body</h1><hr><p>Message Content</p></body></html>"
SmtpMail.SmtpServer = "yoursmtpserver@yourcompany.com"
With mail
.From = from
.Subject = subject
.BodyFormat = MailFormat.Html
.Body = body
.To = "youremailaddress@yourcompany.com"
End With
Try
Console.WriteLine("Stopping McAfee Services...")
stopMcAfee()
Console.WriteLine("Sending Email...")
SmtpMail.Send(mail)
Console.WriteLine("Starting McAfee Services...")
startMcAfee()
Catch exc As HttpException
Console.WriteLine(exc.Message)
Console.WriteLine(exc.InnerException.Message)
Console.WriteLine(exc.InnerException.InnerException.Message)
End Try
End Sub
Mike Labosh [ mlabosh ( at ) hotmail dot com ],
2005-09-28 14:15:30
#