Skip to content

Commit

Permalink
version 5.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jasp402 committed Nov 8, 2024
1 parent b99cdb6 commit 39acf49
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
/qodana.yaml
/todo.txt
!/qodana.yaml
/attachments/
Binary file added Writerside/images/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Writerside/images/image_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions Writerside/topics/readMessage.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The `readMessage()` function in Easy-Yopmail allows you to read the content of a
- **`selector`**: (Optional) A CSS selector to target a specific element within the HTML email body.
- **`attribute`**: (Optional) If a selector is provided, this parameter specifies the attribute of the element to be returned (e.g., "href" for a link).
- **`pathToSave`**: (Optional) Path to save the email HTML as a file.
- **`saveAttachments`**: (Optional) Boolean flag to save email attachments to the project download folder.

## Output

Expand All @@ -26,6 +27,8 @@ The `readMessage()` function returns a promise that resolves with an object cont
- **`from`**: The sender's email address.
- **`date`**: The date the email was received.
- **`deliverability`**: Information about the email delivery.
- **`attachments`**: An array of attachment objects (if `saveAttachments` is enabled).
- **`saveAttachments`**: A boolean flag indicating if attachments were saved.
- **`format`**: The format of the returned content ("TXT" or "HTML").
- **`selector`**: The CSS selector used (if provided).
- **`eq`**: The index of the selected element (if provided).
Expand All @@ -34,6 +37,7 @@ The `readMessage()` function returns a promise that resolves with an object cont
- **`content`**: The content of the email in the specified format.
- **`info`**: A list of warnings or informational messages.


## Mermaid Diagram

```mermaid
Expand Down Expand Up @@ -84,6 +88,37 @@ easyYopmail.readMessage('my-email', 'email-id', { format: 'HTML', pathToSave: '.
});
```

### 4. Read Email Content and Save Attachments

```javascript
easyYopmail.readMessage('my-email', 'email-id', { saveAttachment: true })
.then(message => {
if (message.saveAttachments) {
console.log('Attachments saved to download folder');
}
});

// Output:
// Attachments saved to download folder
attachments: [
{
fullName: 'prueba1.rar',
name: 'prueba1',
extension: 'rar',
file: 'https://yopmail.com//cid?b=jasp402&id=e_ZwDkZGN4ZGVmZQR5ZQNjAGD4AwL5BD==&cd=a&pj=f_m38pqbyv1'
},
{
fullName: 'prueba2.zip',
name: 'prueba2',
extension: 'zip',
file: 'https://yopmail.com//cid?b=jasp402&id=e_ZwDkZGN4ZGVmZQR5ZQNjAGD4AwL5BD==&cd=a&pj=f_m38pqbyg0'
}
]
```
![image.png](image.png)
>**Note:** In order for attachments to be downloaded, the email must contain such files. Please check if your email contains attachments before downloading. This feature also negatively impacts performance, as responses are blocked until the download is complete.
>{style="warning"}
## Code Example

```javascript
Expand Down
2 changes: 1 addition & 1 deletion index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "easy-yopmail",
"version": "5.1.0",
"version": "5.2.0",
"description": "Easy-YOPMail (get mail address, inbox and read mail from YOPMail with nodeJS)",
"main": "index.js",
"engines": {
Expand Down
Loading

0 comments on commit 39acf49

Please sign in to comment.