Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

VB Code for sending emails

Option Explicit
Public Function SendEmail(ByVal vFirstNM As String, ByVal vEmailAdd As String, ByVal vCode As String) As Integer

Dim MsgStr As String

On Error GoTo ErrorHandler
Dim imsg As New CDO.Message
Dim objCDO As New CDO.Message
Dim objBP As CDO.IBodyPart
objCDO.AutoGenerateTextBody = True
objCDO.MimeFormatted = True
objCDO.To = vEmailAdd
objCDO.From = "local@domain.tld"
objCDO.Subject = vFirstNM & " : " & "See the new launch that is turning the Copier Industry on its head"

'objCDO.HTMLBody = "Check this out: image tag here"
objCDO.CreateMHTMLBody ("file://c:/MarketEmail.html")
objCDO.Send

SendEmail = 1
Exit Function
ErrorHandler:
SendEmail = Err.Number
MsgStr = Err.Description
End Function