ReplaceVariable - not defined...?

Armitage2k

Registered User.
Local time
Tomorrow, 06:01
Joined
Oct 10, 2009
Messages
34
Hey,

I am running in a strange error since using a 2003 database under 2007.
When I am trying to send an email, which will pulls the body from a table and then replaces certain keywords with specific data, I get an error the used ReplaceVariable() function is not defined.
I use it under 2003 and it works fine. Even if I follow the error define the function as object, it complains that there is a type mismatch.

Maybe someone can get me in a right direction.
Code:
Private Sub cmdEmail_Click()
Dim EmailApp, NameSpace, Emailsend As Object
Dim strSubject, strFirst, strLast, strChin, strBody, strEmail As String

Set EmailApp = CreateObject("Outlook.Application")
If EmailApp Is Nothing Then Set EmailApp = CreateObject("Outlook.Application")
Set NameSpace = EmailApp.GetNamespace("MAPI")
Set Emailsend = EmailApp.CreateItem(0)

strFirst = [Forms]![Client Details]![First Name]
strLast = [Forms]![Client Details]![Last Name]
strChin = [Forms]![Client Details]![Chinese Name]
strEmail = [Forms]![Client Details]![E-Mail Address]
strBody = DLookup("Message", "Emails", "EmailID = 1")
strSubject = DLookup("Subject", "Emails", "EmailID = 1")

strBody = ReplaceVariable(strBody, "[$FIRSTNAME]", strFirst)
strBody = ReplaceVariable(strBody, "[$LASTNAME]", strLast)
strBody = ReplaceVariable(strBody, "[$CHINESENAME]", strChin)

If IsNull([Email]) Or ([Email]) = "" Then
       MsgBox "There is no E-mail address entered for this person!"
       Exit Sub
       
    Else

    With Emailsend
        .Subject = strSubject
        .To = strEmail
        '.CC = ""
        '.From = "my.email@domain"
        .Body = strBody
        '.BodyFormat = olFormatPlain
        '.Attachments.Add "C:\attachment.txt"
        '.Attach = strFilePath & "\" & strFileName
        '.AttachFile strFilePath & "\" & strFileName, strFileName
        .Display
    End With
    
End If

Set EmailApp = Nothing
Set NameSpace = Nothing
Set Emailsend = Nothing
End Sub

Thanks for the help,
A2k
 
i thought it was just Replace()
 
You need to post your custom ReplaceVariable() function. Is there a reason you are using a custom ReplaceVariable() function instead of the built-in Replace() function?
 

Users who are viewing this thread

Back
Top Bottom