Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1084to1088
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
Inhaltsverzeichnis

Serien-Mail mit Anhang

Serien-Mail mit Anhang
Boulbadaoui
Hallo,
ich versuche mit dem folgenden Makros, einen Serienmail zu gestalten, leider bekomme ich immer die Zeitlauffehlermeldung 7225!
_____________________________________________________________

Sub testmail()
Dim i, empfänger, anlagen, titel, mailtext, An As Variant
Dim Entwurf As Boolean
Dim s_empfänger As String, s_anlagen As String
empfänger = Range("A3").CurrentRegion
anlagen = Range("C3").CurrentRegion
titel = Range("E3").Value
mailtext = Range("G3").Value
Entwurf = True
For Each An In empfänger
s_empfänger = s_empfänger & An & ","
Next
Call SendNotesMail((titel), (anlagen), (s_empfänger), (mailtext), True, Entwurf)
End Sub


'Tabelle in Excel: Spalte A=E-mail-Adressen, Spalte C=Anlagen(mit Pfad Angabe), Spalte E=Titel und Spalte G= E-Mail Text


Sub SendNotesMail(Subject As String, ArrAttachment As Variant, Recipient As String, BodyText As  _
_
_
_
String, SaveIt As Boolean, Entwurf As Boolean)
'Set up the objects required for Automation into lotus notes
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'THe current users notes mail database name
Dim MailDoc As Object 'The mail document itself
Dim AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
Dim Attachment As Variant
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
'Get the sessions username and then calculate the mail file name
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " _
_
_
_
"))) & ".nsf"
'Open the mail database in notes
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.IsOpen = True Then
'Already open for mail
Else
Maildb.OPENMAIL
End If
'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = Recipient
MailDoc.Subject = Subject
MailDoc.body = BodyText
MailDoc.SAVEMESSAGEONSEND = SaveIt
'Set up the embedded object and attachment and attach it
For Each Attachment In ArrAttachment
If Attachment  "" Then
'Bis hier funktioniert, dann nicht mehr'
'Pfad zur zu versendenden Datei
Set AttachME = MailDoc.CREATERICHTEXTITEM(ActiveWorkbook.Path & AWS)
'Fehlermeldung:Laufzeitfehler 7225, obwohl die Datei existiert
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", ActiveWorkbook.Path & AWS)
'MailDoc.CREATERICHTEXTITEM (Attachment)
End If
Next
'Send the document
If Entwurf Then
Call MailDoc.Save(True, True)
Else
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
MailDoc.Send 0, Recipient
End If
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End Sub


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

Betreff
Benutzer
Anzeige
AW: Serien-Mail mit Anhang
26.06.2009 14:32:33
Kawensmann
Welchen Inhalt hat denn die Variable AWS? Und warum ist sie nicht dimensioniert?
AW: Serien-Mail mit Anhang
26.06.2009 18:38:01
Boulbadaoui
Danke,
den Pfad zur zu versendenden der Dateien wird erkennt.
Die Dateien(Pro Empänger ist ein Pdf Datei) werden als Anhang geschickt!
AW: Serien-Mail mit Anhang
27.06.2009 14:40:13
Boulbadaoui
Alle Anlagen(Pdf Anhänge, liegen auf U:\Anlagen), die Name-Konvention name (name@domaine.topdomaine).pdf, bsp für b.schlarb@d-online.de wird b.schlarb.pdf...usw siehe adressen.jpg
AW: Serien-Mail mit Anhang
27.06.2009 14:44:44
Boulbadaoui
Userbild
AW: Serien-Mail mit Anhang
29.06.2009 08:35:13
Boulbadaoui
Hallo,
habe jetzt die Variable AWS definiert und demensioniert.
Zweite sieht so aus:

Sub SendNotesMail(Subject As String, ArrAttachment As Variant, Recipient As String, BodyText As  _
String, SaveIt As Boolean, Entwurf As Boolean)
'Set up the objects required for Automation into lotus notes
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'THe current users notes mail database name
Dim MailDoc As Object 'The mail document itself
Dim AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
Dim Attachment As Variant
ActiveWorkbook.Save
AWS = ActiveWorkbook.FullName
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
'Get the sessions username and then calculate the mail file name
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " _
"))) & ".nsf"
'Open the mail database in notes
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.IsOpen = True Then
'Already open for mail
Else
Maildb.OPENMAIL
End If
'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = Recipient
MailDoc.Subject = Subject
MailDoc.body = BodyText
MailDoc.SAVEMESSAGEONSEND = SaveIt
'Set up the embedded object and attachment and attach it
For Each Attachment In ArrAttachment
If Attachment  "" Then
'Pfad zur zu versendenden Datei
Set AttachME = MailDoc.CREATERICHTEXTITEM(AWS)
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", AWS)
End If
Next
'Send the document
If Entwurf Then
Call MailDoc.Save(True, True)
Else
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
MailDoc.Send 0, Recipient
End If
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End Sub


läuft durch beim ersten versuch, beim nächsten meldet "Laufzeitfehler:7368)Userbild

Anzeige
Serienmail(Serienbrief) mit personalisierte-Anhang
01.07.2009 12:39:10
Boulbadaoui
Hallo,
Bitte um Hilfe! ich kriege das ding nicht zum laufen!
Danke an Alle!

Sub testmail()
Dim i, empfänger, anlagen, titel, mailtext, An As Variant
Dim Entwurf As Boolean
Dim s_empfänger As String, s_anlagen As String
empfänger = Range("A1").CurrentRegion
anlagen = Range("C1").CurrentRegion
titel = Range("E1").Value
mailtext = Range("G1").Value
Entwurf = True
For Each An In empfänger
s_empfänger = s_empfänger & An & ","
Next
Call SendNotesMail((titel), (anlagen), (s_empfänger), (mailtext), True, Entwurf)
End Sub



Sub SendNotesMail(Subject As String, ArrAttachment As Variant, Recipient As String, BodyText As  _
String, SaveIt As Boolean, Entwurf As Boolean)
'Set up the objects required for Automation into lotus notes
'_________________________________________________________
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'THe current users notes mail database name
Dim MailDoc As Object 'The mail document itself
Dim AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
Dim Attachment As Variant
Dim emfänger As Variant
'______________________________________________
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
'Get the sessions username and then calculate the mail file name
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " _
"))) & ".nsf"
'Open the mail database in notes
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.IsOpen = True Then
'Already open for mail
Else
Maildb.OPENMAIL
End If
'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = Recipient
MailDoc.Subject = Subject
MailDoc.body = BodyText
MailDoc.SAVEMESSAGEONSEND = SaveIt
'Set up the embedded object and attachment and attach it
For Each Attachment In ArrAttachment
If Attachment  "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment)
MailDoc.CREATERICHTEXTITEM (Attachment)
End If
If Entwurf Then
Call MailDoc.Save(True, True)
Else
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
MailDoc.Send 0, Recipient
End If
Next
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End Sub


Anzeige

306 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige