Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending one of two emails to a list from Access 1

Status
Not open for further replies.

ChrisCalvert

Technical User
Mar 18, 2002
231
US
My previous thread on this seems to have gone away so here goes: I am looking at creating something to send an email for every record in a table. There is a field for the email addresses. There is also a field that determines what kind of email the person will get (business or consumer).
I have looked through and it seems like the SendObject method is the way to go. However, I still am unclear about the best way to present my templates ( of the two emails). They don't have to have any of the record information in them, so I was hoping there is a way to point to a text or .rtf file. Also I was hoping for some direction on the best place/way to choose which email to send (a field in the records has the info to determine this: If the BusinessCode field is blank it is a consumer).
 
If you think logically about this and write down the steps it becomes easy.

If the BusinessCode is blank
send a consumer email
Otherwise
send a business email
End If

If BusinessCode = "" Then
'Build the parameters for SendObject
objMail.Recipients.Add "John.Jones@aol.com"
objMail.Subject = "Consumer Message"
objMail.Body = 'Insert text from comsumer template
'objMail.Display 'Only if you want to approved before sent
objMail.Send
Else
' Do the same with a different template
End If

You can use the Window Script FileSystemObject or VB file I/O to open the file and read in the text.

Steve King Growth follows a healthy professional curiosity
 
I think I have got it...almost. I have one more question.
With a bit more detail (a code example would be wonderful), how can I read in the text file to the message body?
 
Just this application sample.

Dim intFileNumber As Integer
Dim strTemplate As String

' Set up variable for the logfile
intFileNumber = FreeFile

Open LCase(strFilename) For Input As intFileNumber
Do While Not EOF(1) ' Loop until end of file.
Line Input #intFileNumber, TextLine
strTemplate = strTemplate & TextLine
DoEvents
Loop
Close intFileNumber

Steve King Growth follows a healthy professional curiosity
 
Thanks for all your help, I am almost there.
The only problem is that this is not preserving line breaks.
Currently I am using a .txt, is this a problem with the file format or this read in method?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top