Segue codigo :
Function SendMailTarcisio()
On Error GoTo SendMailError
Plan13.Visible = xlSheetVisible
Sheets("dados").Select
Range("B1").Select
EMailSendTo = Cells(31, 2).Value '"geronimo_andrzejewski@embraco.com" '' Required - Send to address
EMailCCTo = Cells(32, 2).Value '' Optional
EMailBCCTo = Cells(33, 2).Value '' Optional
EmailSubject = Cells(34, 2).Value
''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 = Cells(35, 2).Value
.AddNewLine 1
.AppendText Cells(36, 2).Value
.AddNewLine 3
.AppendText Cells(37, 2).Value
.AddNewLine 1
.AppendText Cells(38, 2).Value
.AddNewLine 1
.AppendText Cells(39, 2).Value
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
SendMailTeste = True
Plan13.Visible = xlSheetHidden
Sheets("Plan1").Select
Range("a5").Select
Exit Function
SendMailError:
Msg = "Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
SendMailTeste = False
End Function
Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel
Postado : 16/10/2012 4:33 am