Boa tarde,
Preciso de uma ajuda, consegui o código abaixo no site http://www.fabalou.com/VBandVBA/lotusnotesmail.asp e funciona muito bem, porém quando preciso colocar mais de um anexo dá um erro "Run-time error '7368'"
Vocês sabem o que devo alterar nesse código para conseguir anexar vários arquivos de uma vez?
Abaixo segue o código:
'This public sub will send a mail and attachment if neccessary to the
'recipient including the body text.
'Requires that notes client is installed on the system.
Public Sub SendNotesMail1(Subject As String, attachment As String, recipient As String, bodytext As String, saveit 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)
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
'Next line only works with 5.x and above. Replace password with your password
'Session.Initialize ("dantunes")
'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 or using above password you can use other mailboxes.
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
MsgBox "E-mail enviado com sucesso!"
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End Sub
O erro acontece na seguinte linha:
Set EmbedObj = AttachME.EmbedObject(1454, "", attachment, "Attachment")
Agradeço a ajuda de todos, preciso acabar esse programa com urgência...
Muito obrigado,
Damião
Preciso de uma ajuda, consegui o código abaixo no site http://www.fabalou.com/VBandVBA/lotusnotesmail.asp e funciona muito bem, porém quando preciso colocar mais de um anexo dá um erro "Run-time error '7368'"
Vocês sabem o que devo alterar nesse código para conseguir anexar vários arquivos de uma vez?
Abaixo segue o código:
'This public sub will send a mail and attachment if neccessary to the
'recipient including the body text.
'Requires that notes client is installed on the system.
Public Sub SendNotesMail1(Subject As String, attachment As String, recipient As String, bodytext As String, saveit 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)
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
'Next line only works with 5.x and above. Replace password with your password
'Session.Initialize ("dantunes")
'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 or using above password you can use other mailboxes.
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
MsgBox "E-mail enviado com sucesso!"
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End Sub
O erro acontece na seguinte linha:
Set EmbedObj = AttachME.EmbedObject(1454, "", attachment, "Attachment")
Agradeço a ajuda de todos, preciso acabar esse programa com urgência...
Muito obrigado,
Damião