3.6k Aufrufe
Gefragt in Tabellenkalkulation von ahorn38 Experte (3.2k Punkte)
Hallo,

ich habe folgenden Code für den Export von im Excel erzeugten .pdf Dateienanhängen ins Outlook 2010:

Sub Versenden()
Sheets("VersandTab").Select
Dim oOL As Object
Dim oOLMsg As Object
Dim oOLRecip As Object
Dim oOLAttach As Object
Dim iRow As Integer, iCounter As Integer
Dim sFile As String, sRec As String, sSub As String
Dim sBody As String
Dim bln
Application.ScreenUpdating = False
Application.DisplayStatusBar = True
bln = Application.DisplayStatusBar
iRow = Cells(Rows.Count, 1).End(xlUp).Row
Set oOL = CreateObject("Outlook.Application")
For iCounter = 2 To iRow
sRec = Cells(iCounter, 1)
sFile = Cells(iCounter, 2)
'MsgBox sFile
sSub = Cells(iCounter, 3)
sBody = Cells(iCounter, 4)
Application.StatusBar = "Sende Datei " & sFile & " an " & sRec & "..."
'MsgBox Application.StatusBar
Set oOLMsg = oOL.CreateItem(0)
With oOLMsg
Set oOLRecip = .Recipients.Add(sRec)
.Subject = sSub
.Body = sBody & vbLf & vbLf
Set oOLAttach = .Attachments.Add(sFile)
.Send
End With
oOLRecip.Resolve
Next iCounter
Set oOL = Nothing
Application.StatusBar = False
Application.DisplayStatusBar = bln
End Sub

Der Code funktioniert einwandfrei. Allerdings habe ich mehrere Outlook-Konten und möchte daraus ein bestimmtes "muster@web.de" ansteuern. Ich habe dieses im Outlook auch als Standardkonto festgelegt, es wird aber leider vom Code nicht angesteuert. Hat jemand einen Tipp???
Gruß
Andreas

11 Antworten

0 Punkte
Beantwortet von coros Experte (4k Punkte)
Hallo Andreas!

Freut mich, dass alles funktioniert. Danke auch für die Rückmeldung.

MfG,
Oliver
[sup]Jeder macht was er will, keiner macht was er soll, aber alle machen mit.[/sup]
...