Results 1 to 5 of 5
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Why not send sheet? (2000 sr-1)

    Option Explicit
    Sub Mail_workbook_Outlook_1()

    Dim OutApp As Object
    Dim OutMail As Object

    Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next

    With OutMail
    .To = "OI24683"
    .CC = ""
    .BCC = ""
    .Subject = "A.L.A. - ADEMPIMENTI LEGGE ANTIRICICLAGGIO"
    .Body = "STATISTICA GIORNALIERA" & "INVIO DEL " & Format(CDate(Now))
    .Attachments.Add ThisWorkbook.Worksheets("STAT_NEW")
    .Send 'Display

    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Why not send sheet? (2000 sr-1)

    You must attach a file from disk. So if you want to send a single sheet, you must first save that sheet in a separate file, and attach that.

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Why not send sheet? (2000 sr-1)

    Solved, tks.
    But the sheet contain a button and before to copy in dir i want to delete it or disable...
    Sub INVIA_STATISTICA()

    Dim OutApp As Object
    Dim OutMail As Object
    Dim TEMPNAME As String
    Dim DATA As Date
    Dim DRIVER, DATA_SALVA As String
    Dim GIORNO, MESE, ANNO As String

    Application.ScreenUpdating = False

    DRIVER = "GCD01F4500DATIPUBBLICAANTIRIC"

    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("STAT_NEW").Copy
    TEMPNAME = DRIVER & "STATISTICA" & "STAT_NEW_" & DATA_SALVA & ".xls"

    ActiveWorkbook.SaveAs TEMPNAME
    ActiveWorkbook.Close
    On Error Resume Next

    With OutMail
    .To = "OI27461" & ";" & "OI32838"
    .CC = "OI29658" & ";" & "OI27570"
    .BCC = ""
    .Subject = "A.L.A. - ADEMPIMENTI LEGGE ANTIRICICLAGGIO" & " *** STATISTICA GIORANLIERA *** AL: " & Format(CDate(Now), "DD/MM/YYYY")
    .Body = ""
    .Attachments.Add TEMPNAME
    .Display 'Send
    End With

    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing

    End Sub

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Why not send sheet? (2000 sr-1)

    Insert the following line after copying the worksheet but before saving it:

    ActiveSheet.DrawingObjects.Delete

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Why not send sheet? (2000 sr-1)

    Simple and elegant!
    tks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •