Sub or Function Not defined (1 Viewer)

Cnoll

New member
Local time
Today, 05:40
Joined
Sep 24, 2020
Messages
3
Hello,

I keep receiving a Sub or Function not defined error message on the below VBA:

Public Function HighEmail()
On Error GoTo HighEmail_Err
Dim fso, fs As Scripting.FileSystemObject
Set fso = New FileSystemObject
Set fs = New FileSystemObject
Dim appOutLook As Object
Dim MailOutLook As Object
Dim SigString As String
Dim Signature As String
Set appOutLook = New Outlook.Application
Set MailOutLook = appOutLook.CreateItem(olMailItem)

'Get Outlook Signature
SigString = Environ("appdata") & _
"\Microsoft\Signatures\myname.htm"
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If

I've gone over and over it and can not find the issue...any help is greatly appreciated.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:40
Joined
Oct 29, 2018
Messages
21,358
Hi. Welcome to AWF!

Which line is giving you the error?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 05:40
Joined
May 21, 2018
Messages
8,463
Is GetBoiler a public function?
 

Cnoll

New member
Local time
Today, 05:40
Joined
Sep 24, 2020
Messages
3
I'm getting the error on the GetBoiler part of the code. Funny thing is that i've used that in another DB and it works fine. But for some reason I keep getting an error in this DB.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:40
Joined
Oct 29, 2018
Messages
21,358
I'm getting the error on the GetBoiler part of the code. Funny thing is that i've used that in another DB and it works fine. But for some reason I keep getting an error in this DB.
Hi. Thanks for the additional information. Looks like @MajP was on the right track. Did you make sure you have a copy of that function/module from the other db into your current db?
 

Cnoll

New member
Local time
Today, 05:40
Joined
Sep 24, 2020
Messages
3
Hi. Thanks for the additional information. Looks like @MajP was on the right track. Did you make sure you have a copy of that function/module from the other db into your current db?
Yes i copied it from the other DB and checked it about 10 times, till i stopped scratching my head and thought...i'm definitely missing something here.
 

Isaac

Lifelong Learner
Local time
Today, 02:40
Joined
Mar 14, 2017
Messages
8,738
Yes i copied it from the other DB and checked it about 10 times, till i stopped scratching my head and thought...i'm definitely missing something here.
Where is GetBoiler function?
Is it in a regular module or behind a Form (in a Form's class module) ?
 

Minty

AWF VIP
Local time
Today, 09:40
Joined
Jul 26, 2013
Messages
10,355
Assuming the GetBoiler function just gets the signature for the user, there is an easier(?) way to get the signature into the email;

Code:
    Dim OutApp As Object
    Dim OutMail As Object
    Dim signature As String
    '-- Standard Email Variables
    Dim Variable_To As String
    Dim Variable_Subject As String
    Dim Variable_Body As String
    Dim Variable_AttachmentFile As String
    Dim Variable_savepath As String
    
     OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)
    On Error Resume Next
    With OutMail
        .BodyFormat = olFormatHTML
        .Display
    End With
    
    signature = OutMail.HTMLBody
        
    With OutMail
    
        .To = Variable_To
        .CC = ""
        .BCC = ""
        .Subject = Variable_Subject
        '.MailItem.ReplyRecipients.Add = "flibble@somehwhere.com"
        '.SentOnBehalfOfName = "flibble@somehwhere.com"
        '.Attachments.Add (Variable_AttachmentFile)
        .HTMLBody = Variable_Body & signature
        .Display   'or use .Send
        .ReadReceiptRequested = False
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:40
Joined
May 7, 2009
Messages
19,175
maybe you should go back to the place where you get your email function to
get the getBoiler() function.

Code:
Function GetBoiler(ByVal sFile As String) As String
    'Dick Kusleika
    Dim fso As Object
    Dim ts As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
    GetBoiler = ts.ReadAll
    ts.Close
End Function

by the way this will Not get you the Image signature you need.
just go back (to the site), there is another function you need to correctly
display the signature.
 
Last edited:

Isaac

Lifelong Learner
Local time
Today, 02:40
Joined
Mar 14, 2017
Messages
8,738
Assuming the GetBoiler function just gets the signature for the user, there is an easier(?) way to get the signature into the email;

Code:
    Dim OutApp As Object
    Dim OutMail As Object
    Dim signature As String
    '-- Standard Email Variables
    Dim Variable_To As String
    Dim Variable_Subject As String
    Dim Variable_Body As String
    Dim Variable_AttachmentFile As String
    Dim Variable_savepath As String
   
     OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)
    On Error Resume Next
    With OutMail
        .BodyFormat = olFormatHTML
        .Display
    End With
   
    signature = OutMail.HTMLBody
       
    With OutMail
   
        .To = Variable_To
        .CC = ""
        .BCC = ""
        .Subject = Variable_Subject
        '.MailItem.ReplyRecipients.Add = "flibble@somehwhere.com"
        '.SentOnBehalfOfName = "flibble@somehwhere.com"
        '.Attachments.Add (Variable_AttachmentFile)
        .HTMLBody = Variable_Body & signature
        .Display   'or use .Send
        .ReadReceiptRequested = False
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
if using this late bound code may need to change olFormatHTML to '2'
this is good as long as the signature you want to add is the default signature on user's default account at runtime

just a few thoughts i had. still waiting for OP to mention where GetBoiler is..
 

Users who are viewing this thread

Top Bottom