I have this code to send e-mail.
First i copy the sheet TEMPLATE as workbook from the active workbook with: Worksheets("TEMPLATE").Copy
(i think this is the first operation to attach the sheet into email, or not?)
and when the code go in: .Attachments.Add ActiveWorkbook have error?????
Code:Sub INVIO_STATISTICA() Dim OutApp As Object Dim OutMail As Object Dim TEMPNAME As String Dim DATA As Date, WS_T As Worksheet Dim DRIVER As String, DATA_SALVA As String Dim GIORNO As String, MESE As String, ANNO As String On Error GoTo errore Application.ScreenUpdating = False Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set OutMail = OutApp.CreateItem(0) DATA = Format(CDate((Now)), "DD/MM/YYYY") GIORNO = Left(DATA, 2) MESE = Mid(DATA, 4, 2) ANNO = Right(DATA, 4) DATA_SALVA = GIORNO & "-" & MESE & "-" & ANNO Worksheets("TEMPLATE").Copy With OutMail .To = "AAAAA" .CC = "" .BCC = "" .Subject = "DDDDDDDD" .HTMLBody = STRBODYTEXT_4 '.Body = "" .Attachments.Add ActiveWorkbook .Display '.Send End With Set OutMail = Nothing Set OutApp = Nothing ' Application.ScreenUpdating = True Exit Sub errore: MsgBox "Errore Numero: " & CStr(Err.Number) & vbCrLf & _ "Descrizione: " & Err.Description & vbCrLf & _ "Sorgente dell'Errore: " & Err.Source Err.Clear End Sub


Reply With Quote


