如何寄信

出自VFP Wiki

在2006年6月12日 (一) 05:13由Elleryq (對話 | 貢獻)所做的修訂版本
(差異) ←上一修訂 | 最新修訂 (差異) | 下一修訂→ (差異)
跳轉到: 導航, 搜尋


目錄

使用MSMAPI

來源

提供者

  • 狐友 saint
  • Ruey

環境

  • 需安裝 Office

範例

oSession = CREATEOBJECT("MSMapi.MapiSession")
oMessage = CREATEOBJECT("MSMapi.MapiMessages")

oSession.LogonUI = .t.
oSession.SignOn

*-- The message control needs to reference the session control's ID.
oMessage.SessionID = oSession.SessionID
oMessage.MsgIndex = -1

*-- Set up our message and send it.
oMessage.Compose
oMessage.msgsubject = "Attachments sent using FoxPro and MAPI"
oMessage.msgnotetext = " Attached are some test files."

*-- Create an array holding the attachment file names.
DIMENSION lcAttachment(2)
lcAttachment(1) = home()+ "samples\data\customer.dbf"
lcAttachment(2) = home()+ "samples\data\customer.cdx"

*-- Attach the files.
FOR lnCount = 1 TO ALEN(lcAttachment)
oMessage.AttachmentIndex = lnCount - 1
oMessage.AttachmentPathName = lcAttachment(lnCount)
ENDFOR

*-- Send the message on its way.
oMessage.send(1) 

使用CDO

來源

提供者

  • 由狐友violet提供
  • 傳遞 html 格式與附件,是由狐友 erwin_ho 提供.

環境

  • Windows 版本: 2000 以後的版本

範例

oMSG = createobject("CDO.Message")
oMSG.To = "violet@kkk.com.tw"
oMSG.From = "violet@kkk.com.tw"
oMSG.Subject = "Hello Email"
oMSG.TextBody = "This is an easy way to create an email"
oMSG.Send()
RELEASE omsg
oMSG.HTMLBody="傳HTML格式"
=oMSG.addattachment("C:\TEST.TXT") <--傳附件

使用JMail

請參考 Ruey 提供的連結.