Before all good morning....guys
I have an application that sends mails with attach files (Worbook+Sheets) from VB trough Lotus Notes. The file to send is in a listbox, so see these:
1 - The only workbook and sheets send, is that the first in the list box. Then it becames the problem. The
second file in the list is send but without contents.
2 - After sending the second file Lotus Notes crush because it can read the memmory.
Finally here goes the code
Code:
'***************************************************************************************************
'Esta função permite que após seleccionar um ficheiro da listbox o envie via NOTES
'**************************************************************************************************
'Abre o ficheiro de indicadores
Set WBSource = Workbooks.Open(Datadir & List1.Text, , True)
If Not Err.Number = 0 Then
MsgBox "Não foi possível abrir o ficheiro de indicadores", 64 + vbOKOnly, AppTitle
Exit Sub
End If
***********************************************************************************************************
Cria um documento com o subject o body e attcha-lhe o ficheiro que seleccionei na Listbox
***********************************************************************************************************
'db.OPENMAIL
Set doc = db.CREATEDOCUMENT()
doc.Form = "Memo"
doc.Subject = Me.Text6.Text
doc.ENCRYPTONSEND = False
Set RTI = doc.CREATERICHTEXTITEM("Body")
doc.Body = Me.Text4.Text
Set F = RTI.EMBEDOBJECT(1454, "", WorkDir & WSMail.Cells(i, 1) & ".xls", "Body")
Set F = Nothing
Flag = doc.Save(True, True)
StatusBar1.Panels(2).Text = "A Enviar..." & WorkDir & WSMail.Cells(i, 1) & ".xls"
Call doc.SEND(False, MailUser)
Set RTI = Nothing
Set doc = Nothing
i = i + 1
*************************************************
Procura o Notes e Fecha
************************************************
'Close Notes Session
db.Close
winHwnd = FindWindow(vbNullString, "Lotus Notes Desktop")
If winHwnd = 0 Then winHwnd = FindWindow(vbNullString, "Workspace at Office - Lotus Notes Desktop")
If winHwnd = 0 Then winHwnd = FindWindow(vbNullString, "Workspace at Office - Lotus Notes Desktop")
If winHwnd <> 0 Then RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
*************************************************************************
Fecha os Worbooks e liberta memória dos objectos criados
************************************************************************
WBSource.Close False
WBMailDef.Close False
'Workbooks.Close
Set session = Nothing
Set db = Nothing
StatusBar1.Panels(2).Text = "Mailing enviado..."
Me.MousePointer = 1
End Sub
