Consegui em partes falta dar uma lapidada em uma parte do codigo. Este ficou assim :
Dim objNotesSession As Object
Dim objNotesMailFile As Object
Dim objNotesDocument As Object
Dim objNotesField As Object
Function SendMail()
On Error GoTo SendMailError
EMailSendTo = "geronimo_andrzejewski@embraco.com" '' Required - Send to address
EMailCCTo = "" '' Optional
EMailBCCTo = "" '' Optional
EmailSubject = "Visões de Custos"
''Establish Connection to Notes
Set objNotesSession = CreateObject("Notes.NotesSession")
''Establish Connection to Mail File
'' .GETDATABASE("SERVER", "FILE")
Set objNotesMailFile = objNotesSession.GetDatabase("", "")
''Open Mail
objNotesMailFile.OPENMAIL
''Create New Memo
Set objNotesDocument = objNotesMailFile.CreateDocument
''Create 'Subject Field'
Set objNotesField = objNotesDocument.AppendItemValue("Subject", EmailSubject)
''Create 'Send To' Field
Set objNotesField = objNotesDocument.AppendItemValue("SendTo", EMailSendTo)
''Create 'Copy To' Field
Set objNotesField = objNotesDocument.AppendItemValue("CopyTo", EMailCCTo)
''Create 'Blind Copy To' Field
Set objNotesField = objNotesDocument.AppendItemValue("BlindCopyTo", EMailBCCTo)
''Create 'Body' of memo
Set objNotesField = objNotesDocument.CreateRichTextItem("Body")
With objNotesField
.AppendText = "Bom Dia"
.AddNewLine 1
.AppendText "Segue planilha com os Codigos para Cadastrar as Visões de Custos."
.AddNewLine 2
.AppendText Cells(1, 1).Value & "______"
.AppendText Cells(1, 2).Value
.AddNewLine 3
.AppendText Cells(2, 1).Value & "______"
.AppendText Cells(2, 2).Value
.AddNewLine 4
.AddNewLine 5
.AppendText "Desde ja agradeço a atenção."
End With
'Anexar planilha no email --- 1454 indica um anexo de arquivo
''objNotesField = objNotesField.EMBEDOBJECT(1454, "", "C:Temptest.xls")
'objNotesField = objNotesField.EmbedObject(1454, "", ActiveWorkbook.FullName)
''Enviar o emaill
objNotesDocument.Send (0)
''Release storage
Set objNotesSession = Nothing
Set bjNotesSession = Nothing
Set objNotesMailFile = Nothing
Set objNotesDocument = Nothing
Set objNotesField = Nothing
''Set return code
SendMail = True
Exit Function
SendMailError:
Msg = "Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
SendMail = False
End Function
Esta parte do codigo abaixo é que falta lapidar :
.AppendText Cells(1, 1).Value & "______"
.AppendText Cells(1, 2).Value
.AddNewLine 3
.AppendText Cells(2, 1).Value & "______"
.AppendText Cells(2, 2).Value
Em vez de separar as colunas pelo traço sera que poderiamos dar um TAB entre elas.
Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel
Postado : 11/01/2012 1:02 pm