Outlook>Excel-Datei an mehrere Adressen
24.05.2002 11:43:36
H.Meinert
zu dem unten aufgeführten Makro soll in einer zusätzlichen Spalte
ein zweiter Empfänger eingetragen werden.
Die Datei soll an beide Empfänger gesendet werden.
Ursprung:
In einer Excel-Tabelle habe ich spaltenweise folgende Angaben: Email-Adressen, Dateinamen, Betreff, Text Wie kann ich auf Basis dieser Daten Outlook starten und die Emails mit den genannten Anlagen und Angaben in den entsprechenden Feldern versenden?
Lösung:
'StandardModule: basMain
Sub Verteilen()
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim intRow As Integer, intCounter As Integer
Dim strFile As String, strRecipient As String, strSubject As String
Dim strBody As String
Dim bolStatusBar
Application.ScreenUpdating = False
Application.DisplayStatusBar = True
bolStatusBar = Application.DisplayStatusBar
intRow = Cells(Rows.Count, 1).End(xlUp).Row
Set objOutlook = CreateObject("Outlook.Application")
For intCounter = 2 To intRow
strRecipient = Cells(intCounter, 1)
strFile = Cells(intCounter, 2)
strSubject = Cells(intCounter, 3)
strBody = Cells(intCounter, 4)
Application.StatusBar = "Sende Datei " & strFile & " an " & strRecipient & "..."
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add(strRecipient)
objOutlookRecip.Type = olTo
.Subject = strSubject
.Body = strBody & vbLf & vbLf
Set objOutlookAttach = .Attachments.Add(strFile)
objOutlookRecip.Resolve
.Send
End With
Next intCounter
Set objOutlook = Nothing
Application.StatusBar = False
Application.DisplayStatusBar = bolStatusBar
End Sub