By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,635 Members | 913 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,635 IT Pros & Developers. It's quick & easy.

email automation

P: n/a
Hi
I use the following code to automatically send email. The code works
perfectly.
I would like to create an advert save it as an html file and then use this
html file as the body of the email.
I do not want to send it as an attachement.
Any ideas how to do this ?

Thanks Alfred

Dim olApp As Outlook.Application
Dim olMailMessage As Outlook.MailItem
Dim olRecipient As Outlook.Recipient
Dim olAttach As Outlook.Attachment
Dim emailstring As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
Set cn = CurrentProject.Connection

Set rs = cn.Execute("SELECT DbGeneralEmail from DbMaster1 ")

Dim AttachmentPath As String
AttachmentPath = "c:\aa\customers.txt"

emailstring = " "
' Do Until rs.EOF
' If Not IsNull(rs!DbGeneralEmail) Then
' emailstring = emailstring + rs!DbGeneralEmail + ";"
emailstring = emailstring + "at****@jam.co.za" + ";" ' for
testing
Set olApp = New Outlook.Application
Set olMailMessage = olApp.CreateItem(olMailItem)
With olMailMessage
.To = emailstring
.BCC = emailstring
.Display
.Subject = "This is 2 test with Outlook"
.Body = "test Body." & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance

If Not IsMissing(AttachmentPath) Then
Set olAttach = .Attachments.Add(AttachmentPath)
End If
.Send
End With
Set olMailMessage = Nothing
emailstring = " "
' End If
' rs.MoveNext
' Loop


Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hello

Not sure if this will work exactly (depending if you want graphics or not).
But you can choose Microsoft HTML object library as a reference. Then, copy
the HTML code into a word doc, for example and replace paragraph marks with
something like

" [para mark] strHTML = strHTML & "

Copy it into your code. Then, instead of .Body, use .HTMLbody = strHTML.

Hope it makes sense.

All the best

Rebecca
"Alfred" <sp**************@hotmail.com> wrote in message
news:bn**********@ctb-nnrp2.saix.net...
Hi
I use the following code to automatically send email. The code works
perfectly.
I would like to create an advert save it as an html file and then use this
html file as the body of the email.
I do not want to send it as an attachement.
Any ideas how to do this ?

Thanks Alfred

Dim olApp As Outlook.Application
Dim olMailMessage As Outlook.MailItem
Dim olRecipient As Outlook.Recipient
Dim olAttach As Outlook.Attachment
Dim emailstring As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
Set cn = CurrentProject.Connection

Set rs = cn.Execute("SELECT DbGeneralEmail from DbMaster1 ")

Dim AttachmentPath As String
AttachmentPath = "c:\aa\customers.txt"

emailstring = " "
' Do Until rs.EOF
' If Not IsNull(rs!DbGeneralEmail) Then
' emailstring = emailstring + rs!DbGeneralEmail + ";"
emailstring = emailstring + "at****@jam.co.za" + ";" ' for
testing
Set olApp = New Outlook.Application
Set olMailMessage = olApp.CreateItem(olMailItem)
With olMailMessage
.To = emailstring
.BCC = emailstring
.Display
.Subject = "This is 2 test with Outlook"
.Body = "test Body." & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance

If Not IsMissing(AttachmentPath) Then
Set olAttach = .Attachments.Add(AttachmentPath)
End If
.Send
End With
Set olMailMessage = Nothing
emailstring = " "
' End If
' rs.MoveNext
' Loop

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.