Skip to content
This repository has been archived by the owner on Jan 10, 2021. It is now read-only.

Commit

Permalink
Add support to set, add and remove flags
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Oct 31, 2019
1 parent 00403bc commit c0241dd
Show file tree
Hide file tree
Showing 6 changed files with 620 additions and 11 deletions.
58 changes: 57 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Mail Client Arduino Library for ESP32 v 2.0.5
# Mail Client Arduino Library for ESP32 v 2.0.6

This library allows ESP32 to send Email with/without attachment and receive Email with/without attachment download via SMTP and IMAP servers.

Expand Down Expand Up @@ -254,6 +254,62 @@ bool readMail(IMAPData &imapData);




**Set the argument to the Flags for message.**

param *`imapData`* - IMAP Data object to hold data and instances.

param *`msgUID`* - The UID of message.

param *`flags`* - The flag list.

return - *`Boolean`* type status indicates the success of operation.

```C++
bool setFlag(IMAPData &imapData, int msgUID, const String &flags);
```
**Add the argument to the Flags for message.**
param *`imapData`* - IMAP Data object to hold data and instances.
param *`msgUID`* - The UID of message.
param *`flags`* - The flag list.
return - *`Boolean`* type status indicates the success of operation.
```C++
bool addFlag(IMAPData &imapData, int msgUID, const String &flags);
```






**Remove the argument from the Flags for message.**

param *`imapData`* - IMAP Data object to hold data and instances.

param *`msgUID`* - The UID of message.

param *`flags`* - The flag list.

return - *`Boolean`* type status indicates the success of operation.

```C++
bool removeFlag(IMAPData &imapData, int msgUID, const String &flags);
```
**Get the Email sending error details.**
return - *`Error details string (String object).`*
Expand Down
70 changes: 70 additions & 0 deletions examples/Set_flag/Set_flag.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Created by K. Suwatchai (Mobizt)
*
* Email: k_suwatchai@hotmail.com
*
* Github: https://github.com/mobizt
*
* Copyright (c) 2019 mobizt
*
*/


#include <Arduino.h>
#include "ESP32_MailClient.h"

#define WIFI_SSID "YOUR_WIFI_SSID"
#define WIFI_PASSWORD "YOUR_WIFI_PASSWORD"

//The Email Reading data object contains config and data that received
IMAPData imapData;

void readEmail();

unsigned long lastTime = 0;

void setup()
{

Serial.begin(115200);
Serial.println();

Serial.print("Connecting to AP");

WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
delay(200);
}

Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());

Serial.println();

Serial.println();

imapData.setLogin("imap.gmail.com", 993, "YOUR_EMAIL_ACCOUNT@gmail.com", "YOUR_EMAIL_PASSWORD");
imapData.setFolder("INBOX");
imapData.setDebug(true);

//Set \Seen and \Answered to flags for message with UID 100
MailClient.setFlag(imapData, 100, "\\Seen \\Answered");

//Add \Seen and \Answered to flags for message with UID 100
//MailClient.addFlag(imapData, 100, "\\Seen \\Answered");

//Remove \Seen and \Answered from flags for message with UID 100
//MailClient.removeFlag(imapData, 100, "\\Seen \\Answered");
}



void loop()
{

}

3 changes: 3 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ readMail KEYWORD2
smtpErrorReason KEYWORD2
imapErrorReason KEYWORD2
sdBegin KEYWORD2
setFlag KEYWORD2
addFlag KEYWORD2
removeFlag KEYWORD2

#########################################
# Methods for IMAP Data object (KEYWORD2)
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=ESP32 Mail Client

version=2.0.5
version=2.0.6

author=Mobizt

Expand Down
Loading

0 comments on commit c0241dd

Please sign in to comment.