Jump to content
alanf

Mark Message as read directly after sending and moving to Sent Items

Recommended Posts

Immediately after sending a message with EmailSend and EmailMoveCurrentMessage (to my "Sent Items" folder), how can i immediately mark that sent message as being read?

 

 

Share this post


Link to post
Share on other sites

Alan,

In order to do this you will need to call EmailOutgoingMessageID after sending to get the message ID then call EmailReadMessages on your "Sent Items" folder and pass in the parameters "readonly=false" and "messageID=$messageID". This will pull in that sent message. Then call EmailGetMessage to iterate to the message. Next, call EmailMessageSetFlag("viewed";"true"). Please note that this will only work with IMAP servers as POP servers do not support message flags. 

Share this post


Link to post
Share on other sites
On 1/6/2017 at 7:00 AM, ryan360Works said:

Alan,

In order to do this you will need to call EmailOutgoingMessageID after sending to get the message ID then call EmailReadMessages on your "Sent Items" folder and pass in the parameters "readonly=false" and "messageID=$messageID". This will pull in that sent message. Then call EmailGetMessage to iterate to the message. Next, call EmailMessageSetFlag("viewed";"true"). Please note that this will only work with IMAP servers as POP servers do not support message flags. 

Ryan,

Thank you for the reply. I have tried to set that up as you directed.  Script does send email and move message to "Sent Items" folder, but does not successfully mark it as read.

 

Here is what I have.  Does this look correct?

 

Thanks!

 

Set Field [ PluginExample::_result; EmailCreate( PluginExample::From ; $CurrentEmailAddress ; PluginExample::Subject)
and
EmailSetBody( PluginExample::Body )
and
EmailAttachFile( $OutputFileName ) ]

Set Field [ PluginExample::_result; EmailSend (
"progress=" & PluginExample::Progress Bar ;
"progresslocation=" & PluginExample::Progress Location )
and
EmailMoveCurrentMessage ( "Sent Items" ) ]

#get message id from what was just sent
Set Variable[ $messageID; EmailOutgoingMessageId ]

Set Field [ PluginExample::_result; EmailReadMessages(
"readonly=false";
"messageID=$messageID";
"mailbox=SENT ITEMS" ;
"max=1") ]

#Iterate to message
Set Field [ PluginExample::_result; EmailGetNextMessage ]
#Mark as read
Set Field [ PluginExample::_result; EmailMessageSetFlag( "viewed";"true" ) ]

Edited by alanf

Share this post


Link to post
Share on other sites

Alan,

Your script looks correct. I recommend stepping through the script and making sure that you are getting "1" when EmailGetNextMessage is called. If you are not getting a "1", then the message is not getting read in. If you do get a "1", add a EmailReadMessageValue after the EmailGetNextMessage call and pass in a value that you can use to identify the message to make sure that it is the correct one. 

Another thing to check would be to make sure you are getting the message ID. EmailGetOutgoingMessageID returns the message ID or "" if there is no message. I also recommend adding some error checking/data validation to your script.

Share this post


Link to post
Share on other sites

@alanf did you ever get this working?


I'm trying to do the same and can't seem to figure it out. 

Share this post


Link to post
Share on other sites

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

×

Important Information

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