Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1816to1820
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Mailversand mit Lotus Notes
11.03.2021 09:30:51
Daniel
Folgender Code erzeugt mir aus einem Tabellenblatt eine PDF und sendet diese per Lotus Notes ( ... wir nutzen kein Outlook).
An sich klappt das auch , NUR mit dem Problem, dass die Email direkt im "Hintergrund" verschickt wird.
Hat jemand eine Idee, was ich anpassen muss, dass zwar das Emailfenster geöffnet und die Datei angehängt wird, ich aber noch Text eingeben kann und den Senden Button selbst drücken muss

Option Explicit
Const EMBED_ATTACHMENT As Long = 1454
Const stPath As String = "c:\Attachments"
Const stSubject As String = "Weekly report"
Const vaMsg As Variant = "The weekly report as per agreement." & vbCrLf & _
"Kind regards," & vbCrLf & _
"Daniel"
Const vaCopyTo As Variant = "name@mail.com"
Sub Send_Active_Sheet()
Dim stFileName As String
Dim vaRecipients As Variant
Dim noSession As Object
Dim noDatabase As Object
Dim noDocument As Object
Dim noEmbedObject As Object
Dim noAttachment As Object
Dim stAttachment As String
'Copy the active sheet to a new temporarily workbook.
'With ActiveSheet
'  .Copy
'  stFileName = .Range("A1").Value
'End With
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
ThisWorkbook.Path & "\Antrag_Mehrarbeit.pdf", Quality:=xlQualityStandard _
, IncludeDocProperties:=False, IgnorePrintAreas:=True, FROM:=1, To:=1, OpenAfterPublish:= _
False
'stAttachment = stPath & "\" & stFileName & ".xls"
stAttachment = ThisWorkbook.Path & "\Antrag_Mehrarbeit.pdf"
'Save and close the temporarily workbook.
'With ActiveWorkbook
'  .SaveAs stAttachment
'  .Close
' End With
'Create the list of recipients.
vaRecipients = VBA.Array("name1@mail.com", "name1@mail.com")
'Instantiate the Lotus Notes COM's Objects.
Set noSession = CreateObject("Notes.NotesSession")
Set noDatabase = noSession.GETDATABASE("", "")
'If Lotus Notes is not open then open the mail-part of it.
If noDatabase.IsOpen = False Then noDatabase.OPENMAIL
'Create the e-mail and the attachment.
Set noDocument = noDatabase.CreateDocument
Set noAttachment = noDocument.CreateRichTextItem("stAttachment")
Set noEmbedObject = noAttachment.EmbedObject(EMBED_ATTACHMENT, "", stAttachment)
'Add values to the created e-mail main properties.
With noDocument
.Form = "Memo"
.sendTo = vaRecipients
.copyTo = vaCopyTo
.Subject = stSubject
.Body = vaMsg
.SaveMessageOnSend = True
.PostedDate = Now()
.Send 0, vaRecipients
End With
'Delete the temporarily workbook.
' Kill stAttachment
'Release objects from memory.
Set noEmbedObject = Nothing
Set noAttachment = Nothing
Set noDocument = Nothing
Set noDatabase = Nothing
Set noSession = Nothing
MsgBox "The e-mail has successfully been created and distributed", vbInformation
End Sub
Das alleine auszukommentieren hilft schonmal nicht
 .Send 0, vaRecipients


6
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Mailversand mit Lotus Notes
11.03.2021 10:49:01
volti
Hallo Daniel,
ich kann jetzt nur vermuten, da ich kein Lotus habe:
Bei Outlook sendet dieses hier die Mail sofort
.Send
und dieses öffnet nur die Mail
.Display
Versuche es einfach mal...
viele Grüße
Karl-Heinz

AW: Mailversand mit Lotus Notes
11.03.2021 11:06:12
Daniel
Das hatte ich schon probiert;
.Display funktioniert leider nicht

AW: Mailversand mit Lotus Notes
11.03.2021 11:21:36
mumpel
"Send" einfach weglassen?

AW: Mailversand mit Lotus Notes
11.03.2021 11:23:25
mumpel
Schau mal hier rein:
Lotus Notes Send EMail from VB or VBA
(auch hier "Send" einfach weglassen).

Anzeige
AW: Mailversand mit Lotus Notes
12.03.2021 06:06:42
Daniel
Ja, auch; Send weglassen alleine hilft aber nicht.
Nach einigem Googeln und ein paar amerikanischen Seiten habe ich ein Brotkrümel gefunden und konnte es lösen
Set workspace = CreateObject("Notes.NotesUIWorkspace")
Call workspace.EDITDOCUMENT(True, noDocument).GOTOFIELD("Body")
Und hier noch für die Nachwelt; vielleicht braucht es ja mal jemand

Option Explicit
Const EMBED_ATTACHMENT As Long = 1454
Const stSubject As String = "Betreff der Mail"
Const vaMsg As Variant = "falls man das möchte, hier einen vorgefertigten text"
Const vaCopyTo As Variant = "copyname@name.tld"
Sub Send_Active_Sheet()
Dim stFileName As String
Dim vaRecipients As Variant
Dim noSession As Object
Dim noDatabase As Object
Dim noDocument As Object
Dim workspace As Object
Dim noEmbedObject As Object
Dim noAttachment As Object
Dim stAttachment As String
' erstellt das PDF von Seite 1 im gleichen Ordner, wie sich das Workbook befindet
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
ThisWorkbook.Path & "\bliblablubt.pdf", Quality:=xlQualityStandard _
, IncludeDocProperties:=False, IgnorePrintAreas:=True, FROM:=1, To:=1, OpenAfterPublish: _
=False
' Bereitstellung des Emailanhangs
stAttachment = ThisWorkbook.Path & "\bliblablub.pdf"
' Empängerliste (bei automatischem Versand) Array
vaRecipients = VBA.Array("maildahin@empfangenix.tld")
' Laden der Lotus COM Objekte
Set noSession = CreateObject("Notes.NotesSession")
Set noDatabase = noSession.GETDATABASE("", "")
'Falls Notes nicht geöffnet ist
If noDatabase.IsOpen = False Then noDatabase.OPENMAIL
' Email erstellen
Set noDocument = noDatabase.CreateDocument
Set noAttachment = noDocument.CreateRichTextItem("stAttachment")
Set noEmbedObject = noAttachment.EmbedObject(EMBED_ATTACHMENT, "", stAttachment)
With noDocument
.Form = "Memo"
.sendTo = vaRecipients
.copyTo = vaCopyTo
' vorgegebens Subjekt
.Subject = stSubject
' Input Box
'.Subject = InputBox("Please Enter the Message Subject", "Message Subject")
'.Body = vaMsg
.SaveMessageOnSend = True
.PostedDate = Now()
'.Send 0, vaRecipients
End With
Set workspace = CreateObject("Notes.NotesUIWorkspace")
Call workspace.EDITDOCUMENT(True, noDocument).GOTOFIELD("Body")
' Speicher leeren
Set noEmbedObject = Nothing
Set noAttachment = Nothing
Set noDocument = Nothing
Set noDatabase = Nothing
Set noSession = Nothing
' MsgBox
MsgBox "Die Mail ist erstellt. Bitte wechseln Sie zu NOTES", vbInformation
End Sub


Anzeige
AW: Mailversand mit Lotus Notes
13.03.2021 08:26:44
mumpel
Leider rückt der Hersteller keine Entwickler-Dokumentation heraus wenn man die Software nicht selber (als Business-Anwender) kauft/mietet.

132 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige