在传统的vb6程序中,我使用完整版本的outlook(而不是outlook express)发送电子邮件,使用下面的代码。效果很好。
我认为这是一个简单的修复方法;我只需要在OutMail对象中设置.from属性,但是在OutMail对象中似乎没有.from属性。(可能叫别的名字?)
如何使用此技术指定发件人电子邮件地址?
Dim mOutlookApp As Object
Set mOutlookApp = GetObject("", "Outlook.application")
Dim olNs As Object
Set olNs = mOutlookApp.GetNamespace("MAPI")
olNs.Logon
Dim OutMail As Object
Set OutMail = mOutlookApp.CreateItem(0)
'Set the To and Subject lines. Send the message.
With OutMail
.To = txtTo
.CC = txtCC
.Subject = txtSubjext
.HTMLBody = txtBody & vbCrLf
Dim myAttachments As Object
Set myAttachments = .Attachments
vAttach = Split(mAttachments, ",")
For i = 0 To UBound(vAttach)
myAttachments.add vAttach(i)
Next i
Dim myFolder As Object
Set myFolder = olNs.GetDefaultFolder(5) 'olFolderSent
Set .SaveSentMessageFolder = myFolder
StatusBar1.Panels(1).Text = "Status: Sending"
.send
End With