2007/05/31

send mail / VBA excel

http://www.rondebruin.nl/sendmail.htm

http://www.paulsadowski.com/WSH/cdo.htm

Keith74


#===============================================================
#===============================================================

maybe that helps:


    Sub NeueMail2Outbox()

    Dim ol, olns, p_out As Outlook.MAPIFolder
    Dim neumail As Outlook.MailItem, empfänger

    Set ol = CreateObject("Outlook.Application")
    Set olns = ol.GetNamespace("MAPI")
    Set p_out = olns.GetDefaultFolder(olFolderOutbox)

    neumail = p_out.Items.Add

    With neumail
    .Recipient.Add "Bernd Meier"
    .Subject = "Einladung"
    .Body = "Einladung zum Gartenfest" _
    & vbCr & "Wann? Am 20. Juni 2000" _
    & vbCr & "Wo? Biergarten Zur Linde, München"
    ' For Each empfänger In neumail.Recipients()
    ' empfänger.Resolve
    ' Next
    ' .Send
    End With


gNeandr

#===============================================================
#===============================================================

http://www.paulsadowski.com/WSH/cdo.htm

that page shows how to use MS CDO

- i enabled its reference, and worked fine with the simple example


    Sub Mail1()

    Set objMessage = CreateObject("CDO.Message")
    objMessage.Subject = "Example CDO Message"
    objMessage.From = "toto@toto.com"
    objMessage.To = "tata@tata.com"
    objMessage.TextBody = "This is some sample message text."

    '==This section provides the configuration information for the remote
    SMTP server.
    '==Normally you will only change the server name or IP.

    objMessage.Configuration.Fields.item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

    'Name or IP of Remote SMTP Server
    objMessage.Configuration.Fields.item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
    = "smtp.toto.com"

    'Server port (typically 25)
    objMessage.Configuration.Fields.item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

    objMessage.Configuration.Fields.Update

    '==End remote SMTP server configuration section==

    objMessage.Send

    End Sub



#===============================================================
#===============================================================


http://www.rondebruin.nl/cdo.htm

Norman Jones

No comments: