2013-01-24 129 views
1

我已经在Excel中编写了一个VB宏,它使用MS Outlook创建和发送电子邮件。从Excel宏创建Thunderbird电子邮件

因此,我创建了一个Outlook.Application,然后创建Outlook.Application.CreateItem(olMailItem)

这一切都很奇妙:)但现在我已经意识到我想部署它的机器没有Outlook,并且获得Outlook的许可副本不是一种选择。那么我怎么才能让这个邮件通过Thunderbird发送呢?

我可以启动使用这个应用程序:

Dim RetVal 
RetVal = Shell("C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe", 1) 

但我不知道我怎样才能为它创建一个邮件项目。它不需要专门使用Thunderbird,我只是选择它,因为它是一个免费的邮件客户端。

+1

是CDO不是一种选择? http://www.rondebruin.nl/cdo.htm –

+0

是的,这是完美的作品!感谢:D – user1934821

回答

1

CDO不是一个选项吗? http://www.rondebruin.nl/win/s1/cdo.htm - 亚洲时报Siddharth溃败

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 

注:如果您收到此错误:运输未能连接到服务器,然后尝试从25 SMTP端口更改为465