insert HtML file in to body of email (inside loop email)

jeudi 30 avril 2015

Hey everyone - thanks for your help
- this works a treat
but now I want to enhance it

what i want to do is inset a html file into the body of the email
I have created a publisher file and saved as html ..say

C:\test\pub1.html
:banghead:

how do I get this in to the body ?

code to date below (not the tidiest - but it works)



Private Sub Command0_Click()


Dim MyDb As DAO.Database
Dim rsEmail As DAO.Recordset

Dim OutApp As Object
Dim OutMail As Object
Dim strAttach1 As String

Dim Attachment As String
Dim RefernceNumber As String
Dim attachments As String

Dim FilenameZ As String
Set MyDb = CurrentDb()
Set rsEmail = MyDb.OpenRecordset("bondqry", dbOpenSnapshot)
Dim FilterZ As String
Dim strID As String
Dim i As Integer



For i = 0 To rsEmail.RecordCount


rsEmail.MoveNext
Next i


With rsEmail
.MoveLast
.MoveFirst


Do Until rsEmail.EOF
DoCmd.OpenReport "Bondreport", acViewPreview, , "RefernceNumber=" & rsEmail.Fields(6) & ""
DoCmd.OpenReport "Bondreport", acViewPreview, , "RefernceNumber=" & rsEmail.Fields(6) & ""

DoCmd.OutputTo acOutputReport, , acFormatRTF, "c:\Test\" & .Fields(6) & ".Doc", False
DoCmd.Close acReport, "Bondreport", acSaveYes


strAttach1 = "C:\test\" & rsEmail.Fields(6) & ".doc" & ""


If IsNull(.Fields(11)) = False Then
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

With OutMail


.to = rsEmail.Fields(11)
.Subject = "" & rsEmail.Fields(6)
.HTMLBody = "some blurb.. tied to a table ? " & vbCrLf & _
"Field A: " & vbCrLf & _
"Field B: " & vbCrLf & _
"Field C: "
'.display
.attachments.Add strAttach1


strID = rsEmail.Fields(6)


.send

End With
End If
.MoveNext
Loop

End With




Set MyDb = Nothing
Set rsEmail = Nothing
End Sub
insert HtML file in to body of email (inside loop email)

0 commentaires:

Enregistrer un commentaire

Labels