如何寄信

出自VFP Wiki

(修訂版本間差異)
跳轉到: 導航, 搜尋
第1行: 第1行:
 +
===使用MSMAPI===
 +
====來源====
 +
*http://fox.hanyu.com.tw/View.aspx?fbId=7&Id=7717
 +
*http://fox.hanyu.com.tw/View.aspx?fbId=1&Id=17394
 +
*http://fox.hanyu.com.tw/View.aspx?fbId=1&Id=15910
 +
*http://fox.hanyu.com.tw/View.aspx?fbId=1&Id=351
 +
*VFP目錄下的...\samples\solution\ole\sendmail.scx
 +
 +
====提供者====
 +
*狐友 saint
 +
 +
====環境====
 +
*需安裝 Office
 +
 +
====範例====
 +
<pre>
 +
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)
 +
</pre>
 +
 +
===使用CDO===
====來源====
====來源====
*http://fox.hanyu.com.tw/View.aspx?fbId=1&Id=18075
*http://fox.hanyu.com.tw/View.aspx?fbId=1&Id=18075

在2005年2月9日 (三) 10:05所做的修訂版本

目錄

使用MSMAPI

來源

提供者

  • 狐友 saint

環境

  • 需安裝 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") <--傳附件