T
Tony Vrolyk
I am using Outlook automation to create an HTML email and insert data from
my application. The automation uses a template in which there are several
bits of text like [EMPLOYEE], [FROM], etc. I am tyring to use the replace
function to replace each of these with data but only the first on in a
series works. The second and subsequent ones appear to simply get skipped or
fail without errors. the data being used to replace is some from a DAO
recordset and some from the current form. Here is a snippet of what I am
doing
'open recordset, CreateItemFromTemplate, set variables, etc
strSubject = Replace(.Subject, "[EMPLOYEE]", Me.cboEmployee.Column(1))
strBody = .HTMLBody
strBody = Replace(strBody, "[CONTACT]", rst!ContactName)
strBody = Replace(strBody, "[EMPLOYEE]", strOutEmployee)
strBody = Replace(strBody, "[FROM]", strFrom)
strBody = Replace(strBody, "[TO]", strTo)
strBody = Replace(strBody, "[RETURN]", strReturn)
'several lines to build up the strTeamMember variable
strBody = Replace(strBody, "[ADMINTEAM]", strTeamMember)
.HTMLBody = strBody
'etc...
In the subject the [EMPLOYEE] gets replaced OK. In the body [CONTACT] and
[ADMINTEAM] get replaced OK but the others are just left alone. Maybe the
problem should be obvious and I am just having a dumb a** attack. So if
anyone can help it would be appreciated.
Tony
my application. The automation uses a template in which there are several
bits of text like [EMPLOYEE], [FROM], etc. I am tyring to use the replace
function to replace each of these with data but only the first on in a
series works. The second and subsequent ones appear to simply get skipped or
fail without errors. the data being used to replace is some from a DAO
recordset and some from the current form. Here is a snippet of what I am
doing
'open recordset, CreateItemFromTemplate, set variables, etc
strSubject = Replace(.Subject, "[EMPLOYEE]", Me.cboEmployee.Column(1))
strBody = .HTMLBody
strBody = Replace(strBody, "[CONTACT]", rst!ContactName)
strBody = Replace(strBody, "[EMPLOYEE]", strOutEmployee)
strBody = Replace(strBody, "[FROM]", strFrom)
strBody = Replace(strBody, "[TO]", strTo)
strBody = Replace(strBody, "[RETURN]", strReturn)
'several lines to build up the strTeamMember variable
strBody = Replace(strBody, "[ADMINTEAM]", strTeamMember)
.HTMLBody = strBody
'etc...
In the subject the [EMPLOYEE] gets replaced OK. In the body [CONTACT] and
[ADMINTEAM] get replaced OK but the others are just left alone. Maybe the
problem should be obvious and I am just having a dumb a** attack. So if
anyone can help it would be appreciated.
Tony