我在Excel中编写了一个VB宏,它使用MS Outlook创建并发送电子邮件。
所以我创建了一个Outlook.Application
,然后创建了一个Outlook.Application.CreateItem(olMailItem)
。
这一切都很奇妙:)但现在我已经意识到我想部署它的机器没有Outlook,并且获得Outlook的许可副本不是一种选择。那么如何通过Thunderbird发送电子邮件呢?
我可以使用以下方式启动应用程序:
Dim RetVal
RetVal = Shell("C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe", 1)
但我不确定如何为它创建邮件。它不需要专门使用Thunderbird,我只是选择它,因为它是一个免费的邮件客户端。
答案 0 :(得分:1)
CDO不是一种选择吗? http://www.rondebruin.nl/win/s1/cdo.htm - Siddharth Rout
Sub CDO_Mail_Small_Text()
Dim iMsg As Object
Dim iConf As Object
Dim strbody As String
' Dim Flds As Variant
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
' iConf.Load -1 ' CDO Source Defaults
' Set Flds = iConf.Fields
' With Flds
' .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
' .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
' = "Fill in your SMTP server here"
' .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
' .Update
' End With
strbody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"This is line 4"
With iMsg
Set .Configuration = iConf
.To = ""
.CC = ""
.BCC = ""
.From = ""
.Subject = "New figures"
.TextBody = strbody
.Send
End With
End Sub
注意:如果出现此错误:传输无法连接到服务器,请尝试将SMTP端口从25更改为465