在内部网络中,怎样不用smtp发信.只要实现内部互发就行了

下面的例子使用的smtp,这样的话占用了外发服务器sss的资源,如何才能实现内部互送。

Option Explicit

Private Sub Command2_Click()
' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Windows 2000 Library
Dim iConf As New CDO.Configuration
Dim Flds As ADODB.Fields
Set Flds = iConf.Fields

' Set the configuration for Network Send
Flds(cdoSendUsingMethod) = cdoSendUsingPort
'replace the server name to your exchange server name, exchange server should have IMC installed
'Flds(cdoSMTPServer) = "mail.microsoft.com"
Flds(cdoSMTPServer) = "sss"
'SMTP port number, default is 25
Flds(cdoSMTPServerPort) = 25
Flds(cdoSMTPConnectionTimeout) = 30
Flds(cdoSMTPAccountName) = "xxx"
Flds(cdoSendUserReplyEmailAddress) = """xxx"" <philiuliu@benq.com>"
Flds(cdoSendEmailAddress) = """xxx"" <xxx@xxx.com.cn>"
' ... other settings
Flds.Update

Dim iMsg As New CDO.Message
Set iMsg.Configuration = iConf
iMsg.To = "xxx@xxx.com.cn"
iMsg.HTMLBody = "aaa"
iMsg.Send

' go on to use Message object

End Sub
[1231 byte] By [philiu-哲别] at [2008-6-10]
# 1
感谢您使用微软产品。

用CDO1.21,走MAPI protocol 而不是SMTP protocol.这样就不会用你的SMTP 端口。

下面的代码转发一封邮件,您可以修改来实现发送邮件的功能。

'This code sample is dependent upon the CDO version 1.2 library being
'installed on the target computer.
'
Dim objSession As MAPI.Session
Dim objMsgColl As Messages
Dim objMsg1 As Message
Dim objFwdMsg As Message

Private Sub Form_Load()
'Create Session and Logon.
Set objSession = CreateObject("mapi.session")
objSession.Logon
Set objMsgColl = objSession.Inbox.Messages
'First Message.
Set objMsg1 = objMsgColl.GetFirst
Set objFwdMsg = objMsg1.Forward
'BEGIN objFwdMsg BODY CONSTRUCTION
'
'For RTF in the body, uncomment the following lines of code.
'For plain text, uncomment the first line, which isn't really
'required for RTF, except that if you happen to forward the message
'to a client that cannot read RTF, populating this property allows
'that client to display the non-RTF variant of the body.
'
'objFwdMsg.Text = objMsg1.Text
'objFwdMsg.Fields.Add CdoPR_RTF_COMPRESSED, _
'objMsg1.Fields(&H10090102).Value
'
'END objFwdMsg BODY CONSTRUCTION
objFwdMsg.Recipients.Add Name:="YourRecipEmailNameHere"
objFwdMsg.Recipients.Resolve
objFwdMsg.Send

objSession.Logoff
Set objSession = Nothing
Unload Me

End Sub



希望这些讯息对您有帮助。

- 微软全球技术中心 DTA技术支持

本贴子仅供Codefund的用户作为参考信息使用。其内容不具备任何法律保障。您需要考虑到并承担使用此信息可能带来的风险。具体事项可参见使用条款 (http://www.Codefund.cn/microsoft/terms.shtm)。
# 2
CDO version 1.2 library 应该怎样应用 Dim objSession As MAPI.Session不通过

vb 中只有for window2000
philiu-哲别 at 2007-10-21 > top of Msdn China Tech,企业开发,Exchange Server...
# 3
感谢您使用微软产品。

您有否把CDO 1.21 加入到VB的Reference列表中呢? 同时您的机器上需装有CDO 1.21的对象库。该对象库可被下列产品装入:

Outlook 98, Outlook 2000 (缺省不会装入),Exchange server 5.0;Exchange server 5.5等

装入该对象库后,您就可以使用它了。

希望这些讯息对您有帮助。

- 微软全球技术中心 DTA技术支持

本贴子仅供Codefund的用户作为参考信息使用。其内容不具备任何法律保障。您需要考虑到并承担使用此信息可能带来的风险。具体事项可参见使用条款 (http://www.Codefund.cn/microsoft/terms.shtm)。
# 4
Thank you acptdta

可以发了,但是我想发html的mail,应该设置哪个属性呢?
philiu-哲别 at 2007-10-21 > top of Msdn China Tech,企业开发,Exchange Server...