SMTP Crashes

Giganews Newsgroups
Subject: SMTP Crashes
Posted by:  Jeremy Cowles (jeremy.cowles[no…@m]asifl.com)
Date: Mon, 23 Feb 2004

Hi all,

The following code crashes at the point when the SMTP object is created.
Note that I'm using .NET 2002, but I have the 1.1 framework installed as
well.

This is the line that crashes:
        SmtpSender = New SMTP()

Exception:
        An unhandled exception of type
'Indy.Sockets.IndyExceptionCore.EIdWrapperException'
        occurred in indy.sockets.dll
        Additional information: Invalid PInvoke metadata format.

Full code listing (VB):
__________________

Imports Indy.Sockets
Imports Indy.Sockets.IndySMTP
...
        Dim OutgoingMessage As New IndyMessage.Message()
        Dim SmtpSender As SMTP

        With OutgoingMessage
            .From.Text = "[email address]"
            .Recipients.Add.Text = "[email address]"
            .Subject = "TEST E-MAIL"
            .Body.Text = "This is only a test"
        End With

        SmtpSender = New SMTP()
        SmtpSender.Host = "smtp-server"

        Try
            SmtpSender.Connect()
        Catch ex As Exception
            '// could not connect
            Throw
        End Try

        Try
            SmtpSender.Send(OutgoingMessage)
        Catch ex As Exception
            '// could not send
            Throw
        Finally
            If Not SmtpSender Is Nothing AndAlso SmtpSender.Connected() Then
                SmtpSender.Disconnect()
            End If
        End Try
_________________________________

Thanks,
Jeremy

Replies