一勺抹茶

分享代码的乐趣

 

VB6使用MAPI如何傳送MIME格式的郵件

這是MAPI傳送郵件的VB6程式,它只能傳送純文字,請問有沒有人知道要如何才能傳送HTML格式的郵件。
Private Sub Command1_Click() 'user clicks send
MAPISession1.SignOn 'sign on
If MAPISession1.SessionID <> 0 Then 'signed on

With MAPIMessages1
.SessionID = MAPISession1.SessionID
.Compose
.RecipAddress = "abc@abc.com"
.MsgSubject = "title"
.MsgNoteText = "body text"
.Send False
End With
Exit Sub
End If
End Sub

將要發送的信件內容嵌入 HTML 代碼 (body 裡)
就可以發送 HTML 格式信件了
Private Sub cmdSendMail_Click()

  Dim objMail as Object
  Set objMail=CreateObject("CDFONTS.DLL")

  Dim content as String

  content ="<html><head>"
  content = content +"<title>測試HTML格式</title></head>"
  content = content +"<body><h2>測試信件<h2>"
  content = content +"<table>"
  content = content +"<tr><td>測test1</td></tr>"
  content = content +"<tr><td>試test2</td></tr>"
  content = content +"</table>"
  content = content +"</body></html>"

  With ObjMail
  .From= "test@test.com"
  .To= "test@test.com"
  .Subject="發信的主旨"
  .Body=content
  .BodyFormat=0
  .EmailFormat=0
  .Send
  End With

  Set objMail=nothing

End Sub

posted on 2006-01-01 19:14  MoreTea  阅读(390)  评论(0)    收藏  举报

导航