N
Nutcroft5
Please help!
I have the following bit of code that has worked absolutely fine. However i
have packaged the database and it is failing on this bit of code. I have
installed it on a machine that has no previous version of access - only the
runtime 2007. I have another bit of code that just opens a blank email which
works fine and i have used late binding to avoid outlook reference problems.
I have tried removing the whole transfertext command and just using an
existing filename.txt but that still doesn't work. Any ideas??
Set db = CurrentDb
Set rs = db.OpenRecordset("path")
rs.MoveFirst
DoCmd.TransferText acExportDelim, "emailcontent export", "emailcontent",
"c:\FileName.txt"
Set olapp = CreateObject("outlook.application")
Set objmail = olapp.CreateItem(olMailItem)
Set fso = New FileSystemObject
Set strbody = fspenTextFile("c:\filename.txt", ForReading)
bod = strbody.ReadAll
bod = Replace(bod, vbCrLf, "<BR>" & vbCrLf)
strbody.Close
With objmail
.HTMLBody = "Hi " & Me![First Name] & "<br>" & "<br>" & bod
.Display
.To = emailaddress
.Subject = "Welcome!"
Do
path = rs.Fields!Location
.Attachments.Add (path)
rs.MoveNext
Loop Until rs.EOF
End With
Kill ("c:\FileName.txt")
I have the following bit of code that has worked absolutely fine. However i
have packaged the database and it is failing on this bit of code. I have
installed it on a machine that has no previous version of access - only the
runtime 2007. I have another bit of code that just opens a blank email which
works fine and i have used late binding to avoid outlook reference problems.
I have tried removing the whole transfertext command and just using an
existing filename.txt but that still doesn't work. Any ideas??
Set db = CurrentDb
Set rs = db.OpenRecordset("path")
rs.MoveFirst
DoCmd.TransferText acExportDelim, "emailcontent export", "emailcontent",
"c:\FileName.txt"
Set olapp = CreateObject("outlook.application")
Set objmail = olapp.CreateItem(olMailItem)
Set fso = New FileSystemObject
Set strbody = fspenTextFile("c:\filename.txt", ForReading)
bod = strbody.ReadAll
bod = Replace(bod, vbCrLf, "<BR>" & vbCrLf)
strbody.Close
With objmail
.HTMLBody = "Hi " & Me![First Name] & "<br>" & "<br>" & bod
.Display
.To = emailaddress
.Subject = "Welcome!"
Do
path = rs.Fields!Location
.Attachments.Add (path)
rs.MoveNext
Loop Until rs.EOF
End With
Kill ("c:\FileName.txt")