Windows Server 2003 + VB6 + SMTP; html content-type not working

204 Views Asked by At

Server: Windows 2003 r3

Program is supposed to automatically send out emails when they appear in a folder.

The issue that I am having is I can't find any support for the object that is being created.

I am trying to send a email using the text/html content-type and the emails being sent keep being received with the text/plain and the html is just normally displaying as text

The object being created is:

oMail As SMTP

I've tried

oMail.IsBodyHtml = True

And

oMail.MessageFormat = 1

All the tutorials online i've seen use

Dim oSmtp As EASendMailObjLib.Mail

Below is the entire function

Public Function sEnd(oMail As SMTP, MailToSend() As OutMail, ByVal i As Integer) As     Boolean


On Error GoTo SendEmail_Err

Dim result

' Reset Smtp err code
iSmtpErr = 0

' Go thru the list of Mail to send
With MailToSend(i)

    If .Status = EMO_TO_SEND Then

        DoEvents
        ''''''''''''''''''''''''''''''''''''''
        ' Load Winsock
        oMail.WinsockLoaded = True

        ' Specify Domain, Host and Mail Port
        oMail.MailServer = sOutboundDomain
        oMail.MailPort = iOutboundMailPort

        DoEvents
        'oMail.Action = a_ConnectToServer
        oMail.Action = a_ResetHeaders
        ' oMail.IsBodyHtml = True

        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        ' Specify Mail contents: Sender, Recipient, subject, body, ..
        oMail.From = .SenderEmailAddr
        oMail.To = .RecipientEmailAddr
        oMail.SUBJECT = .SUBJECT
        oMail.Date = Format(Now, "ddd, dd mmm yyyy hh:mm:ss") & Space(1) & sTimeZone
        oMail.MessageText = .Body
        ' oMail.MessageFormat = 1
        oMail.OtherHeaders = X_MAILER & Space(1) & sXMailer

        ' Send Message
        oMail.Action = a_SendMessage

        .Status = EMO_SENT
        .TimeSent = Now

        DoEvents
        ' Quit
        oMail.Action = a_DisconnectFromServer

    End If
End With

sEnd = True
Exit Function
SendEmail_Err:
On Error Resume Next

If iSmtpErr >= 25005 And iSmtpErr <= 26005 Or _
    iSmtpErr = 20302 Or iSmtpErr = 20163 Or _
    iSmtpErr = 20162 Then
    ' Changed to handle invalid email address error - July 20, 1999
    ' Or iSmtpErr = 0 Then
    ' Winsock/connection error
    MailToSend(i).Status = EMO_NO_CONNECTION
    RaiseAlert USER_CONNECTION_ERR, ""
Else
    MailToSend(i).Status = EMO_FAILED_TO_SEND
End If
' Log error
Call LogError(CLng(iSmtpErr), MailToSend(i).FileName & ":" & Error, "Send")
' Put in to handle invalid email address error - July 20, 1999
oMail.Action = a_DisconnectFromServer
oMail.Action = a_Idle
sEnd = True
Exit Function

End Function

Thanks a lot for any input!

0

There are 0 best solutions below