日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python讀取Outlook電子郵件具體方法

從事電子郵件營銷,準(zhǔn)入opt-in郵箱列表是必不可少的。你可能已經(jīng)有了準(zhǔn)入列表,同時還使用電子郵件客戶端軟件。如果你能從電子郵件客戶端中導(dǎo)出準(zhǔn)入列表,那這份列表想必是極好的。

我使用一些代碼來將 outlook 配置中的所有郵件寫入一個臨時文件中,現(xiàn)在讓我來嘗試解釋一下這些代碼。

首先你需要導(dǎo)入 win32com.client,為此你需要安裝 pywin32:

pip install pywin32

我們需要通過 MAPI 協(xié)議連接 Outlok:

outlook=win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")

然后從 outlook 配置中獲取所有的賬戶:

accounts= win32com.client.Dispatch("Outlook.Application").Session.Accounts;

在然后需要從名為 emaileri_al 的收件箱中獲取郵件:

def emailleri_al(folder):
messages = folder.Items
a=len(messages)
if a>0:
for message2 in messages:
try:
sender = message2.SenderEmailAddress
if sender != "":
print(sender, file=f)
except:
print("Ben hatay?m")
print(account.DeliveryStore.DisplayName)
pass
try:
message2.Save
message2.Close(0)
except:
pass

你需要進(jìn)入所有賬戶的所有收件箱中獲取電子郵件:

for account in accounts:
global inbox
inbox = outlook.Folders(account.DeliveryStore.DisplayName)
print("****Account Name**********************************",file=f)
print(account.DisplayName,file=f)
print(account.DisplayName)
print("***************************************************",file=f)
folders = inbox.Folders
for folder in folders:
print("****Folder Name**********************************", file=f)
print(folder, file=f)
print("*************************************************", file=f)
emailleri_al(folder)
a = len(folder.folders)
if a>0 :
global z
z = outlook.Folders(account.DeliveryStore.DisplayName).Folders(folder.name)
x = z.Folders
for y in x:
emailleri_al(y)
print("****Folder Name**********************************", file=f)
print("..."+y.name,file=f)
print("*************************************************", file=

下面是完整的代碼:

import win32com.client
import win32com
import os
import sys
f = open("testfile.txt","w+")
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
accounts= win32com.client.Dispatch("Outlook.Application").Session.Accounts;
def emailleri_al(folder):
messages = folder.Items
a=len(messages)
if a>0:
for message2 in messages:
try:
sender = message2.SenderEmailAddress
if sender != "":
print(sender, file=f)
except:
print("Error")
print(account.DeliveryStore.DisplayName)
pass
try:
message2.Save
message2.Close(0)
except:
pass
for account in accounts:
global inbox
inbox = outlook.Folders(account.DeliveryStore.DisplayName)
print("****Account Name**********************************",file=f)
print(account.DisplayName,file=f)
print(account.DisplayName)
print("***************************************************",file=f)
folders = inbox.Folders
for folder in folders:
print("****Folder Name**********************************", file=f)
print(folder, file=f)
print("*************************************************", file=f)
emailleri_al(folder)
a = len(folder.folders)
if a>0 :
global z
z = outlook.Folders(account.DeliveryStore.DisplayName).Folders(folder.name)
x = z.Folders
for y in x:
emailleri_al(y)
print("****Folder Name**********************************", file=f)
print("..."+y.name,file=f)
print("*************************************************", file=f)
print("Finished Succesfully")

文章題目:Python讀取Outlook電子郵件具體方法
文章源于:http://m.5511xx.com/article/dphgchi.html