在内部网络中,怎样不用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
感谢您使用微软产品。
用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)。