MrGoodbyte
Programmer
Hi There
I am using the following code to send an e-mail in VB. It works 100% except that I need to send embedded HTML. If I send embedded HTML then it actually shows the tags. I saw some sample code to send HTML using CDONTS but I cannot get CDONTS to work at all on my pc.
Thanks in advance for any help.
I am using the following code to send an e-mail in VB. It works 100% except that I need to send embedded HTML. If I send embedded HTML then it actually shows the tags. I saw some sample code to send HTML using CDONTS but I cannot get CDONTS to work at all on my pc.
Thanks in advance for any help.
Code:
Sub MailDetail(Subject As String, Message As String)
'----------------------------------------------------------------------
' Name: MailDetail
'
' Description: This procedure sends mail
'
' Inputs: The Subject and Body of the email message are passed
' to this procedure as parameters.
'----------------------------------------------------------------------
On Error GoTo ErrorHandler
Dim objSession As Object
Dim objMessage As Object
Dim objRecipient As Object
Dim objRecipients As Collection
'Create the Session Object
Set objSession = CreateObject("mapi.session")
'Logon using the session object
'Specify a valid profile name if you want to
'Avoid the logon dialog box
objSession.Logon profileName:="MS Exchange Settings"
'Add a new message object to the OutBox
Set objMessage = objSession.Outbox.Messages.Add
'Set the properties of the message object
objMessage.Subject = Subject
objMessage.Text = Message
'Add a recipient object to the objMessage.Recipients collection
Set objRecipient = objMessage.Recipients.Add
'Set the properties of the recipient object
objRecipient.Name = "russellj@aforbes.co.za" '<---Replace this with a valid
'display name or e-mail alias
objRecipient.Type = mapiTo
objRecipient.Resolve
'Send the message
objMessage.Send showDialog:=False
'MsgBox "Message sent successfully!"
'Logoff using the session object
objSession.Logoff
End Sub