Question Help: Send mail Asynchronously in NET1.1

leighton

New member
Joined
Jul 17, 2009
Messages
1
Programming Experience
Beginner
Hi,

Could some one please help me know why this is not working ?
Im trying the send a mail asynchronously. The code below does'nt seem to work. Could any one help me ?

Thanks
Leighton


VB.NET:
Imports System.Web.Mail


Public Class Class1


    Public Delegate Sub DelegatetoSendMail()

    Public Shared Sub Main()
        Dim x As New DelegatetoSendMail(AddressOf SendMail)

        Try
            'SendMail()   ' this works
            x.BeginInvoke(Nothing, Nothing)  'this doesnt 

        Catch ex As Exception

        End Try
    End Sub

    Public Shared Sub SendMail()
        Dim msg As New MailMessage
        msg.From = "admin@mycompany.com"
        msg.To = "me@mycompany.com"
        msg.Subject = "Test Mail"
        msg.Body = "Test Mail"
        msg.BodyFormat = MailFormat.Html

        SmtpMail.SmtpServer = "exchserver1.mycompany.com"
        Try
            SmtpMail.Send(msg)
        Catch ex As Exception
            Dim strError As String
            strError = ex.ToString()
        End Try
    End Sub


End Class
 
Back
Top