1

I have written a VB macro in Excel which creates and sends an email using MS Outlook.

So I create an Outlook.Application, and then create an Outlook.Application.CreateItem(olMailItem).

This all works fantastically :) But now I have realized the machine I wanted to deploy it on does not have Outlook, and getting a licensed copy of Outlook is not an option. So how can I make this send an email through Thunderbird instead?

I can launch the application using this:

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

But I'm not sure how I can create a mail item for it. It does not need to use Thunderbird specifically, I just picked it because it was a free mail client.

4

1 に答える 1

1

CDO はオプションではありませんか? http://www.rondebruin.nl/win/s1/cdo.htm – シッダールス ルート

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 

注: このエラーが発生した場合: The transport failed to connect to the server then try to change the SMTP port from 25 from 465

于 2015-03-02T01:12:09.587 に答える