ich benutze zum versenden einer Arbeitsmappe folgenden VBA-Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Address = ("$C$8") Then
On Error GoTo fehler
If Application.MailSystem = xlMAPI Then
ActiveWorkbook.SendMail Recipients:=[D13], Subject:=[D14]
MsgBox "Die Mail wurde mit xlMAPI versendet."
GoTo ende
Else
Dim wb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim iMsg As Object
Dim iConf As Object
Dim Flds As Variant
Set wb = ActiveWorkbook
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
TempFilePath = Environ$("temp") & "\"
TempFileName = wb.Name & " " & Format(Now, "yymmdd-hh.mm") & ".xls"
wb.SaveCopyAs TempFilePath & TempFileName
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1
Set Flds = iConf.Fields
With Flds
.Item("http:// _
schemas.microsoft.com/cdo/configuration/sendusing")
= 2
.Item("http:// _
schemas.microsoft.com/cdo/configuration/smtpserver")
= [D17] 'SMTP Server
.Item("http:// _
schemas.microsoft.com/cdo/configuration/smtpserverport")
= 25
.Update
End With
With iMsg
Set .Configuration = iConf
.To = [D13] 'Empfänger
.CC = ""
.BCC = ""
.From = "" & [D15] & "" 'Name - Adresse
.Subject = [D14]
.TextBody = "Excel-Datei im Anhang"
.AddAttachment TempFilePath & TempFileName
.Send
End With
Kill TempFilePath & TempFileName
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
MsgBox "Die Mail wurde mit xlNoMailSystem versendet."
GoTo ende
End If
fehler:
MsgBox "Fehler.Mail nicht gesendet."
ende:
Cancel = True
End If
End Sub
Das funktioniert zwar ganz gut, aber es gibt User die haben Outlook installiert, aber nicht eingerichtet, weil die z.B. Thunderbird (Mozilla) verwenden. Nun erkennt Excel aber die Installation von Outlook und stellt viele Fragen... Wenn ich direkt mit CDO senden will kommt bei installiertem Outlook immer ein Fehler bei .send.
Ist es möglich, trotz installiertem Outlook über CDO zu senden? Wie müßte ich Outlook umgehen?