Integration: Outlook
Tích hợp sâu DVDAddin với Microsoft Outlook — không chỉ Send Email batch, mà còn import inbox, parse attachment, automate workflow.
Use cases
1. Send Email hàng loạt qua Outlook
→ Xem Send Email.
Cơ bản: bảng Excel → Outlook COM → mỗi hàng = 1 email.
2. Import inbox archive
→ Xem Import Email.
Outlook PST/OST → Excel table → search, filter, analyze.
3. Auto-categorize email theo AI
Combine Import Email + DvdAskGemini:
=DvdAskGemini("Email này thuộc loại: Spam / Quảng cáo / Công việc / Cá nhân?\nSubject: " & B2 & "\nBody: " & C2)→ Cell D2 = category auto-detected.
Filter Excel + Send Email response tự động (nếu category = "Quảng cáo" → archive).
4. Track responses của client
Workflow:
- Send Email batch → 50 client nhận BBNT.
- Mỗi client phản hồi qua email → vào Inbox.
- Import Email từ folder Inbox → bảng
Responses. - Match Subject
Re: BBNT MC-01với cột MaCT của bảng gốc. - Update cột
Statusthành "Approved" / "Need Revision" tự động.
Outlook COM patterns
DVDAddin gọi Outlook qua COM API. Patterns thường gặp:
Open Outlook instance
dynamic outlookApp = Microsoft.VisualBasic.Interaction.CreateObject("Outlook.Application");Nếu Outlook đang chạy → reuse instance. Nếu chưa → khởi động.
Get folder
dynamic ns = outlookApp.GetNamespace("MAPI");
dynamic inbox = ns.GetDefaultFolder(6); // 6 = Inbox
dynamic items = inbox.Items;OutlookFolder constants:
- 3 = Deleted Items
- 4 = Outbox
- 5 = Sent Items
- 6 = Inbox
- 9 = Calendar
- 10 = Contacts
- 13 = Journal
- 16 = Notes
- 19 = Junk Email
Iterate emails
foreach (dynamic mail in items)
{
string from = mail.SenderEmailAddress;
string subject = mail.Subject;
string body = mail.Body;
DateTime received = mail.ReceivedTime;
// ...
}DVDAddin Import Email implement đúng pattern này.
Outlook Categories integration
Outlook có Categories (label màu). DVDAddin có thể đọc/ghi category qua COM:
Read category trong Import
Khi import email, addin thêm cột Category:
| Subject | From | Date | Category |
|---|---|---|---|
| BBNT MC-01 phê duyệt | [email protected] | 2026-05-15 | Approved |
| BBNT MC-02 cần sửa | [email protected] | 2026-05-16 | Pending |
(Category set thủ công trong Outlook trước khi import.)
Set category từ Excel
(Tính năng chưa implement — sẽ thêm 2.8.x.)
Mục đích: Excel mark email = "Processed" → Outlook cũng hiển thị mark.
Calendar integration
Import lịch họp
DVDAddin có thể đọc Outlook Calendar:
Bảng output:
| Subject | Start | End | Location | Organizer | Attendees |
|---|---|---|---|---|---|
| Họp BCH Tuần 20 | 2026-05-18 09:00 | 2026-05-18 11:00 | Phòng họp A | [email protected] | (10 người) |
Use case: PM nhập lịch họp từ Outlook → Excel để analytics (số họp/tuần, tổng giờ họp).
(Tính năng plan 2.8.x.)
Create event từ Excel
Bảng Excel có cột Date / Time / Subject → tự tạo event Outlook Calendar:
Bảng:
2026-05-18 09:00 | 2026-05-18 11:00 | Họp BCH Tuần 20 | Phòng A | Hùng@..., Lan@...DVDAddin command: "Create Outlook events from Excel".
→ Cells convert thành calendar entries → mời các thành viên.
(Plan 2.9.x.)
Contacts integration
Import từ Outlook → Excel
Outlook Contacts → bảng Excel có columns: Name, Email, Phone, Company, Address.
Phù hợp khi: chuẩn bị mail list cho Send Email.
Sync 2 chiều
Excel master list ↔ Outlook Contacts:
- Excel update → push lên Outlook.
- Outlook update → pull về Excel.
(Plan 2.9.x.)
Email signature management
DVDAddin signature config:
- Preferences → Email → paste HTML/text.
Sử dụng:
- Send Email → auto append signature.
Signature riêng cho mỗi client
Bảng có cột Signature riêng cho từng email:
- A: signature gửi CĐT lớn (formal).
- B: signature gửi thầu phụ (casual).
Send Email loop qua bảng → chèn signature theo cột.
(Tính năng chưa expose qua dialog — workaround: bao signature vào cột Body.)
Auto-reply rules
Outlook có Rules built-in. DVDAddin có thể tạo rule từ Excel:
(Plan 2.9.x.)
Use case:
- Email subject contains "BBNT" + sender domain
@cdt.com→ auto-reply "Đã nhận, sẽ xử lý trong 24h".
Performance khi xử lý nhiều email
Outlook chậm với folder > 5000 emails
Pattern: thay vì iterate inbox.Items toàn bộ, dùng Items.Restrict:
dynamic filtered = items.Restrict("[ReceivedTime] > '2026-05-01'");
foreach (dynamic mail in filtered) { ... }→ Outlook filter trước khi iterate → nhanh hơn 10-100x.
DVDAddin Import Email auto dùng Restrict khi user set date filter.
Cache COM object
Mở Outlook instance 1 lần, reuse cho nhiều operation:
private dynamic _outlook;
dynamic GetOutlook()
{
if (_outlook == null)
_outlook = Microsoft.VisualBasic.Interaction.CreateObject("Outlook.Application");
return _outlook;
}→ Tiết kiệm ~500ms cho mỗi command (skip CreateObject).
Troubleshooting Outlook integration
#1 — "Outlook is not running"
DVDAddin cần Outlook đã chạy. Workaround:
- Tự khởi động Outlook trước.
- Hoặc trong code: gọi
outlookApp.Application.Visible = trueđể force khởi động.
#2 — Outlook 32-bit vs 64-bit conflict
Excel 64-bit + Outlook 32-bit (hoặc ngược lại) → COM call fail.
Fix: cài Outlook + Excel cùng bitness (cùng 64-bit hoặc cùng 32-bit).
#3 — Outlook security warning
Outlook 2007+ có security prompt khi 3rd-party app access:
"A program is trying to access email addresses you have stored in Outlook. Do you want to allow this?"
Fix:
- Trust Center → Programmatic Access → "Never warn me about suspicious activity (not recommended)".
- Hoặc tốt hơn: cài antivirus chính hãng (Outlook check AV → trust nếu có).
#4 — Send email bị bounce / không tới
- Check Sent Items folder — email đã được Outlook accept chưa.
- Check Junk folder phía nhận.
- Reduce send rate (delay 2-5s giữa mỗi mail).
#5 — Attachment file lock
DVDAddin generate file PDF + Send Email ngay → file có thể vẫn lock bởi process generation.
Fix: thêm delay 1-2s giữa generate và send. Hoặc tắt Open after generation option.
Liên quan
- Send Email — chi tiết send batch.
- Import Email — chi tiết import.
- Workflow: Nghiệm thu hàng loạt — combine Outlook + Word + Excel.
- Integration: Word — Word integration patterns.