sendEmail Function in DTS
In lieu of using MAPI mail to send a user confirmation email, I have opted to use the sendEmail function of sql mail subsystem. I can send a text email no problem, but I now want to send an HTML email but am having a bit of difficulty. The pickup directory path is at the bottom of the code below, and I have changed the type of email from text to html, but everytime I put an HTML doc in the pickup directory, it immediately sends doc somewhere, but I'm not sure where. Can someone advise me on the steps to send an HTML email using the sendEmail function, as shown below?? thanks in advance.
'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************
Function Main()
Main = DTSTaskExecResult_Success
set myConn = CreateObject("ADODB.Connection")
myConn.open "Provider=SQLOLEDB;Data Source=;Initial Catalog=;User ID=;password="
set myRS = myConn.execute("select advertiseremail, advertisername, accountnumber from table where Ademail is not null ")
if not myRS.eof then
do while not myRS.eof
call SendEmail("test@test.com",myRS("AdEmail"), "Listing.", "Dear " & myRS("advertisername") & vbcrlf & vbcrlf &"Thank you for placing a listing in the classifieds. As a part of your advertising package, your listing will be displayed on our condo internet marketing portal<http://development.test.com>, for XX days." & vbcrlf & vbcrlf & "As part of your advertising package, the price of your this listing, you are entitled to modify and enhance your listing with Customer Support Team" & vbcrlf &"test.test.com" & vbcrlf & "xxx.xxx.xxxx")
myRS.movenext
loop
end if
set myRS = nothing
End Function
Function SendEmail(sender,recipient,subject,body)
set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory")="c:\inetpub\mailroot\p ickup"
.Update
End With
With iMsg
Set .Configuration = iConf
.To = recipient
.From = sender
.Subject = subject
.htmlBody = body
.Send
End With
set iMsg = nothing
set iConf = nothing
end function
|