Results 1 to 4 of 4
  1. #1
    SidCharming is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2018
    Location
    Minneapolis, MN
    Posts
    27

    Unhappy Redemption email error "Variable not defined"

    What am I missing in my code? everything is registered (DLL) and it worked fine yesterday. Wondering if IT did something, but I want to verify before I speak with them.

    Code:
    Public Function SendMail(AddrTo As String, _
                                 AddrCC As String, _
                                 AddrBCC As String, _
                                 Subj As String, _
                                 MsgBody As String, _
                    Optional strAttachments As String) As Boolean
       
        Dim AttachArray() As String ' Contains attachment file names
        Dim AttachItem As Variant   ' Single attachment
        Dim Success As Boolean      ' Whether the function completed successfully
        Dim Test As New RDOSession
           '- Log into email using current users credentials:
        Test.Logon
        Set mail = Test.GetDefaultFolder(olFolderOutbox).Items.Add("IPM.Note")
       
        On Error GoTo ErrorHandler:
    
    
    
    
        mail.Subject = Subj
        mail.HTMLBody = MsgBody
        mail.Recipients.Add AddrTo
    The error: "Compile Error: Variable not defined"


    happens on row SET MAIL = Test.GetDefaultFolder(olFolderOutbox).Items.Add("I PM.Note")


    Thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,522
    It says you did not DIM mail.
    It doesn't know what MAIL is.

    do you need to use MAIL var?
    Can you remove the "SET MAIL =' and just run the Test.getFolder?
    its adding,so I don't see the need to assign it.
    create MAIL another way.

  3. #3
    SidCharming is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2018
    Location
    Minneapolis, MN
    Posts
    27
    Okay, I ran a vanilla code using Redemption and it worked successfully... I am finding the Function that handles the Redemption portion of the code. This is called from a subroutine that gathers and calls this in a loop of emailing individual files found in a folder. The subroutine in debug mode contains the values but when the next action in debug is to go into the function... all values are gone and it gives me Compile Error: Variable not defined which points to the Set mail line. Which I now believe is not the problem... the Locals window says <No Variables>.

    Why is it there is data on the line calling the function, but one more action (go into the function) gives the error and no variables?!?!

  4. #4
    SidCharming is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2018
    Location
    Minneapolis, MN
    Posts
    27
    The solution is not as expected. I went through nearly every line of code bit by bit and it just never made sense... My only outcome was that somehow the code or system got corrupt. I reverted to a backup copy of the database and updated the code to reflect the updates and it works fine. And where I got the source code to make changes to the backup was the 'BROKEN' version.

    Sometimes the answer isn't so clear (IMO).

    =\

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Compile error "variable not defined"
    By CHEECO in forum Access
    Replies: 11
    Last Post: 03-30-2016, 05:39 PM
  2. Replies: 6
    Last Post: 02-11-2016, 02:05 PM
  3. Replies: 1
    Last Post: 03-14-2013, 12:39 PM
  4. Replies: 1
    Last Post: 12-14-2012, 12:32 AM
  5. Error: "User-defined type not defined"
    By mastromb in forum Programming
    Replies: 10
    Last Post: 01-08-2010, 02:57 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums