bei uns wird grad von IBM Notes auf Outlook umgestellt. Kein Problem, für beides hab ich _ bereits das passende Makro parat.
Private Sub SendMail_Outlook(sSubject As String, sTo As String, sCC As String, sText As String)
'original Outlook Code by mumpel / www.herber.de / 11.04.2013 11:23:25
'http://www.herber.de/forum/messages/1308295.html
Dim olApp As Object
Dim olOldBody As String
'Make Email
Set olApp = CreateObject("Outlook.Application")
With olApp.CreateItem(0)
.GetInspector.Display
olOldBody = .htmlBody
.To = sTo
.cc = sCC
.Subject = sSubject
.htmlBody = sText & olOldBody
.Attachments.Add myFile
End With
End Sub
Sub SendMail_Notes(sSubject As String, sTo As String, sCC As String, sText As String)
Dim Maildb As Object
Dim MailDbName As String
Dim MailDoc As Object
Dim Session As Object
Dim vAn As Variant
'Lotus Notes initialisieren
Set Session = CreateObject("Notes.NotesSession")
Set Maildb = Session.currentdatabase
Set MailDoc = Maildb.CreateDocument
MailDoc.Form = "Memo"
vAn = Split(sTo, " ; ") 'Empfänger Array
MailDoc.sendto = vAn 'Empängeradresse setzen
MailDoc.Subject = sSubject 'Betreff des Mails
MailDoc.SAVEMESSAGEONSEND = True
Set Workspace = CreateObject("Notes.NotesUIWorkspace") ' **durch das öffnen des Dokumentes _
durch NotesUIWorkspace**
Call Workspace.EDITDOCUMENT(True, MailDoc) ' **erreicht man das die eingestellte _
Signatur aus den **
Set doc = Workspace.CURRENTDOCUMENT ' **Lotus Notes Optionen eingefügt wird _
_
Call doc.GOTOFIELD("Body")
Call doc.INSERTTEXT(sText)
'Call doc.Send(True)
Set Maildb = Nothing
Set MailDoc = Nothing
Set Session = Nothing
End Sub
Jetzt könnte ich natürlich die Auswahl, welches Programm zum versenden verwendet wird, dem User überlassen und bei fehlauswahl eine Fehlermeldung hinnehmen:
Sub SendWhat()
Dim sText As String
Dim sTo As String
Dim sCC As String
Dim sSubject As String
sTo = "Frank Farmer ; Karl Ransaier "
sCC = ""
sSubject = "Todays File"
If MsgBox("Haben Sie Outlook (ja) oder immer noch Notes (nein) ?", vbYesNo) = 6 Then
sText = "Dear Colleages
find mail attached
more text with possbile html "
Call SendMail_Outook(sSubject, sTo, sCC, sText)
Else
sText = "Dear Colleagues " & Chr(10) & "find attached something without html"
Call SendMail_Notes(sSubject, sTo, sCC, sText)
End If
End Sub
Aber das ist nicht gut - erstens sind die meisten meiner Anwender bereits mental überfordert wenn sie den VBA-Editor nur sehen, zweitens gerneriert IBM Notes die Fehlermeldung (Memo not Found) innerhalb von Notes und nicht an VBA, mann muss also hin und her clicken.
Kann VBA direkt abfragen, welches Mailprogramm installiert ist? Also in Pseudocode so:
Sub SendWhat()
Dim sText As String
Dim sTo As String
Dim sCC As String
Dim sSubject As String
sTo = "Frank Farmer ; Karl Ransaier "
sCC = ""
sSubject = "Todays File"
Dim Outlook_Installed As Boolean
Dim Notes_Installed As Boolean
set Outlook_Installed = prüfe ob Outlook installiert ist
set Notes_installed = prüfe ob IBM Notes installiert ist
If Outlook_Installed Then
sText = "Dear Colleages
find mail attached
more text with possbile html _
_
b>"
Call SendMail_Outlook(sSubject, sTo, sCC, sText)
Else
If Notes_Installed Then
sText = "Dear Colleagues " & Chr(10) & "find attached something without html"
Call SendMail_Notes(sSubject, sTo, sCC, sText)
Else
MsgBox ("Es wurde kein Mailprogramm gefunden")
End If
End If
End If
End Sub
Kann mir dafür jemand korrekten Code geben?
LG,
Klaus