Jump to content

EmailMoveCurrentMessage can not find folder


This topic is 2245 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

I just received the Email plugin and am trying to use it to send out some emails and then move them to the "Sent" folder on the IMAP server.  EmailMoveCurrentMessage reports that the "Sent" folder can not be found.  Thinking it might be a naming issue I also tried "Sent Items", with the same result, as well as creating another folder "Schools" on the server with the result being the same (except EmailMoveCurrentMessage reports "Schools" can not be found.  I am including the relevant script steps to see if someone might suggest why it is not working for me, but seems to work for others...  There are two relevant scripts ("Main Send Script" and "Check Connections" which just verifies that there are connections to the SMTP and IMAP servers) which I am including with irrelevant steps and Error Checking and Reporting deleted.

//  MAIN SEND SCRIPT

Set Variable [ $$TESTING; Value:0 ]
Set Variable [ $$FAKE; Value:1 ]

#Get our email to send if any
Perform Script [ “Find Email To Send” ]
// Error checking deleted

Go to Layout [ “EMail” (EMail) ]
Set Variable [ $email_ID; Value:EMail::EMail_ID ]

Set Variable [ $result; 
    Value:EmailRegister( NMV Submissions::g_emailLicenseKey ; "XXX" ) 
        and 
    EmailCreate( EMail::From ; "" ; EMail::Subject ) 
        and 
    EmailSetBody( GetAsCSS (EMail::Body) ; "html" ) 
        and 
    EmailAttachFile( EMail::Attachment1 ) 
        and 
    EmailAttachFile( EMail::Attachment2 ) ]

    // Error checking and reporting deleted

#We have created a valid email, so start looping through the school records
Go to Layout [ “School” (School) ]
If [ $$FAKE ]
    Perform Script [ “Find Fake Schools” ]
Else
    Show All Records
End If

Set Variable [ $SuccessCount; Value:0 ]
Set Variable [ $FailureCount; Value:0 ]

Go to Record/Request/Page [ First ]
Loop
    Set Variable [ $School_ID; Value:School::School_ID ]

    #Create new school_email record for each school record
    // Record creation and default values initialization deleted
    
    #Perform the substitution to the email body
    Set Variable [ $result; Value:EmailBodySubstitute( "ZZPrincipal NameZZ" ; School::Principal ) ]
    // Error Checking and Reporting Deleted

    #Set the recipient
    Set Variable [ $result; Value:EmailRecipients( School::PrincipalFriendlyEmail ) ]
    // Error Checking and Reporting Deleted
    
    #Check that we have or can re-establish an SMTP connection. Abort if not...
    Perform Script [ “Check Connections” ]
    If [ Get(ScriptResult) = 0 ]
        Set Variable [ $FailureCount; Value:$FailureCount + 1 ]
        Set Variable [ $result; Value:EmailDisconnect ]
        Exit Script [ ]
    End If

    #Try to Send the email
    If [ not $$TESTING ]
        Set Variable [ $result; Value: 
            EmailSend( "progress=true" ) 
                and
            EmailMoveCurrentMessage( "Sent" ) ]  <<-----  Plugin Reports Error Here: ("Sent not found")

        // Error Checking and Reporting deleted
    Else
        // Simulated emailing steps deleted
    End If

    Go to Layout [ “School” (School) ]
    Go to Record/Request/Page [ Next; Exit after last ]
End Loop
Set Variable [ $result; Value:EmailDisconnect ]
Show Custom Dialog [ Title: "Complete"; Message: "Email Send has completed." & ¶ & " Success Count = " & $SuccessCount & ¶ & " Failure Count = " & $FailureCount; Default Button: “OK”, Commit: “Yes” ]


// CHECK CONNECTIONS SCRIPT

#Failure = 0; Success = 1
Set Variable [ $smtpResult; Value:1 ]
Set Variable [ $imapResult; Value:1 ]
Set Variable [ $count; Value:0 ]

If [ not EmailOutboundIsConnected ]
    Loop
        Set Variable [ $smtpResult; 
            Value:EmailConnectSMTP( NMV Submissions::SMTP Host ; NMV Submissions::Username ; NMV Submissions::Password; "ssl=true" ) ]
        Exit Loop If [ $smtpResult = 1 ]
        Set Variable [ $count; Value:$count + 1 ]
        Exit Loop If [ $count > 3 ]
    End Loop
End If

Set Variable [ $count; Value:0 ]
If [ not EmailInboundIsConnected ]
    Loop
        Set Variable [ $imapResult; 
            Value:EmailConnectIMAP( NMV Submissions::IMAP Host ; NMV 
            Submissions::Username ; NMV Submissions::Password; "ssl=true" ) ]
        Exit Loop If [ $imapResult = 1 ]
        Set Variable [ $count; Value:$count + 1 ]
        Exit Loop If [ $count > 3 ]
    End Loop
End If

If [ $imapResult = 0 or $smtpResult = 0 ]
        Show Custom Dialog [ Title: "Error"; Message: "Unable to establish SMTP and/or IMAP connection. 3 retries were attempted.";                   Default Button: “OK”, Commit: “Yes” ]
        Exit Script [ Result: 0 ]
End If

#If we got here then we were able to successfully connect or re-connect
Exit Script [ Result: 1 ]

Link to comment
Share on other sites

Hi sfmoore,

    Try calling EmailListMailBoxes to query the server for the names of the folders. Make sure you make it recursive like so EmailListMailboxes( ""; true ). In Gmail, and probably other IMAP servers,  folders can have [Gmail] prepended to the name of the folder like the below output of EmailListMailboxes on a Gmail account: 

INBOX
Junk E-mail
Notes
Processed
Random
[Gmail]
[Gmail]/All Mail
[Gmail]/Drafts
[Gmail]/Important
[Gmail]/Sent Mail
[Gmail]/Spam
[Gmail]/Starred
[Gmail]/Trash

 

Link to comment
Share on other sites

  • Newbies

Bingo!!  

INBOX.Sent was what I was needing in this case.  Hero points for you.

Oops.  Spoke too soon.  I get the following error message, which I can't decipher since I've already called EmailCreate(...) earlier on in the script:

Before moving a message you must call EmailCreate (for copying outgoing message) or EmailGetNextMessage (for moving incoming messages)

Link to comment
Share on other sites

This topic is 2245 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.