> For the complete documentation index, see [llms.txt](https://docs.icpc1hn.work/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.icpc1hn.work/ung-dung-n8n/doc-du-lieu-tu-mail-ghi-vao-googlesheet.md).

# Đọc dữ liệu từ Mail ghi vào GoogleSheet

**B1:** Bấm tạo mới **Create Workflow**

<figure><img src="/files/ByoB3iKY3Lul6rCexcs2" alt=""><figcaption></figcaption></figure>

**B2:** Thêm node **Schedule Trigger**

Bấm dấu **"+"** tìm **On a schedule**&#x20;

<figure><img src="/files/2XCDzhbxz08yIfByVdS2" alt=""><figcaption></figcaption></figure>

Cấu hình thời gian, ví dụ ảnh trên đang **set workflow sẽ chạy mỗi 5 phút/lần** ⇒ sau đó bấm **Add Rule**

<figure><img src="/files/eZ5Cy65qdiIV9QpBylhB" alt=""><figcaption></figcaption></figure>

**B3:** Thêm node **Gmail**

Lấy thông tin từ mail nội bộ **@cpc1hn.com.vn**

* Chọn dấu **"+"**
* Tìm **IMAP**
* Chọn **MailBox Get Many**

<figure><img src="/files/zMh20lAwT0yHzYY3ljZ6" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/VfHYlxTSxLoRXmLGpdP5" alt=""><figcaption></figcaption></figure>

Chọn **Set up credential**

<figure><img src="/files/kVnjXZOZLWlblLAMWiYD" alt=""><figcaption></figcaption></figure>

Nhập Tài khoản + Mật khẩu mail do công ty cấp

Host: nhập **mail.cpc1hn.com.vn**

Post: **933**

Bấm **Save**

<figure><img src="/files/AVNYocSGjzPryrIUxtqj" alt=""><figcaption></figcaption></figure>

**Kết nối Mail thành công**

<figure><img src="/files/EYRIHnvCCTy4UvLEAGuj" alt=""><figcaption></figcaption></figure>

**Resource** chọn **Mail**

**Operation** chọn **Get Many**

**Mailbox** ⇒ Chọn **From list** ⇒ chọn thư mục cần lấy thông tin (có thể là **Inbox, Sent, các nhãn khác**,...)

**Include Message Part** chọn **Text Content,...**

<figure><img src="/files/37oG26byqguVFRpOi1o7" alt=""><figcaption></figcaption></figure>

Hoàn thành kết nối với mail nội bộ

<figure><img src="/files/1IT2O8N9HsKsh0RIxTV3" alt=""><figcaption></figcaption></figure>

**B4:** Thêm node **Google Sheets**

Bấm dấu **"+"** ⇒ chọn **Google Sheets** ⇒ chọn **Append row in sheet**

<figure><img src="/files/OkzRFE2D5NtLUNWoe9SN" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/kbTo9w9qJdwUEcExmk7c" alt=""><figcaption></figcaption></figure>

Đăng nhập vào Google

<figure><img src="/files/vZXndRZf5esA8OChrLwZ" alt=""><figcaption></figcaption></figure>

Nhập **Client ID** và **Client Secret** được tạo từ bước **Tạo API key của Google (xem lại bước này)**

**Sau đó chọn Sign in with Google**

<figure><img src="/files/4HE9pSxyBZW3eX4pu9ly" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/LqzlcCbYqDsLy1Uc5EEk" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/F6wjBo1XBKHhQfWcpiQ9" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/gwZgv1rkPWpm49168fq7" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/A8QBIOqpR3gdqGqU1409" alt=""><figcaption></figcaption></figure>

Kết nối thành công

<figure><img src="/files/rLRtZzFc79W4zUjfzvzr" alt=""><figcaption></figcaption></figure>

**B5: Ghi dữ liệu vào GoogleSheet**

*Lưu ý: Cần tạo sẵn file trên GoogleSheet mục đích là ghi thêm dữ liệu vào sheet này từ n8n.*

*Tên cột đặt phụ thuộc vào nhu cầu sử dụng của mỗi người*

<figure><img src="/files/IH243GeCKblkldFJYpjh" alt=""><figcaption></figcaption></figure>

Sau khi có file như trên, quay lại n8n chọn như hình

Lưu ý chỗ Document By ID, ta lấy ID như sau

Ví dụ: Link googlesheet là [https://docs.google.com/spreadsheets/d/<mark style="color:$danger;">1lBLDWyYBz4Y-M7pqJnacorDTFXknt-IgZqUlNzr4qp4</mark>/edit?gid=0#gid=0](https://docs.google.com/spreadsheets/d/1lBLDWyYBz4Y-M7pqJnacorDTFXknt-IgZqUlNzr4qp4/edit?gid=0#gid=0) thì ID sẽ là [<mark style="color:$danger;">1lBLDWyYBz4Y-M7pqJnacorDTFXknt-IgZqUlNzr4qp4</mark>](https://docs.google.com/spreadsheets/d/1lBLDWyYBz4Y-M7pqJnacorDTFXknt-IgZqUlNzr4qp4/edit?gid=0#gid=0)

<figure><img src="/files/z9DCmoIoF5nQMbGZ8til" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/NvrOG2DpgSc9xD900TSE" alt=""><figcaption></figcaption></figure>

{% embed url="<https://youtu.be/J4PFO3Z2IjM>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.icpc1hn.work/ung-dung-n8n/doc-du-lieu-tu-mail-ghi-vao-googlesheet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
