2016-08-09 67 views
0

對於之前的錯誤語法我很抱歉,在Python中使用蓮花筆記發送郵件時發生了情況我嵌入郵件中的鏈接不會生成爲鏈接(不可點擊,並生成像純文本)在doc.Body和鏈接不可見使用doc.HTMLBody。使用Python中的Lotus Notes發送電子郵件時無法創建鏈接

sess=win32com.client.Dispatch("Notes.NotesSession") 
db = sess.getdatabase('','') 
db.openmail 
agent=db.getAgent("DeleteOldDocs") 
doc=db.createdocument 
doc.SendTo = recipients 
doc.Subject = subject 
doc.Body = "Test link http://www.thislink.com" 
doc.HTMLBody = "<a href='http://www.thislink.com'>Link</a>" 
doc.send(0) 

如何在電子郵件中發送可點擊的鏈接?

,這是例如:

This email send by program, and as You can see the link is not clickable and must be copy first then paste to the browser. This is not convenient for the client

+1

通過'http://'是多麼的URL啓動。沒有反斜槓。 –

+0

@KlausD。我已經使用雙斜槓,仍然沒有生成鏈接。 –

回答

1

使用NotesMIMEEntitycreate a HTML formatted mail

你的榜樣應該是這樣的,那麼:

sess=win32com.client.Dispatch("Notes.NotesSession") 
db = sess.getdatabase('','') 
stream = sess.CreateStream 
sess.ConvertMIME = False 
doc = db.CreateDocument 
doc.Form = "Memo" 
body = doc.CreateMIMEEntity() 
header = body.CreateHeader("Subject") 
header.SetHeaderVal(subject) 
header = body.CreateHeader("To") 
header.SetHeaderVal(recipients) 
stream.writetext("<html><body>") 
stream.writetext("Test link http://www.thislink.com <a href='http://www.thislink.com'>Link</a>") 
stream.writetext("</body></html>") 
body.SetContentFromText(stream, "text/HTML;charset=UTF-8", 1728) 
doc.Send(0) 
sess.ConvertMIME = True 
+0

感謝您的回答先生,我在這部分body = doc.CreateMIMEEntity再次出現問題,我得到這樣的錯誤>。像我想念的東西.. –

+0

這可能是一個python特定的語法問題。它是否適用於'body = doc.CreateMIMEEntity()'? –

+0

[已解決]太好了! :)非常感謝您的先生,這是我可以解決很長時間的問題。 –

相關問題