Mail aus Excel über Notes
28.04.2006 16:48:02
Torsten
bei folgendem Code erhalte ich die Fehlermeldung "Rich text item Attachement already exists":
Public
Function SendNotesMail(Subject As String, Attachment As String, Recipient As String, BodyText As String, SaveIt As Boolean)
'von Alex_D aus Herber's Excel Forum)
Dim Maildb As Object 'Die Mail-Datenbank
Dim UserName As String 'Der Notes-Benutzername des SENDENDEN Users
Dim MailDbName As String 'Der Name der Maildatenbank des SENDENDEN Users
Dim MailDoc As Object 'Das Mail-Dokument selbst
Dim AttachME As Object 'Das Attachment-Richtextfile-Object
Dim Session As Object 'Die Notes-Session
Dim EmbedObj As Object 'Das Attachment
'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
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
MailDoc.CREATERICHTEXTITEM ("Attachment")
End If
'Send the document
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
MailDoc.SEND 0, Recipient
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End Function
und zwar an dieser Stelle: MailDoc.CREATERICHTEXTITEM ("Attachment")
Könnt Ihr mir weiterhelfen? Unter W2000 ist dieser Code fehlerlos durchgelaufen.
Vielen Dank für Eure Hilfe.
Gruß
Torsten