Moderatori: Anthony47, Flash30005
Sub Invioemail_FoglioAllegato()
Dim OutApp As Object, OutMail As Object
Dim EmailAddr As String, Subj As String
Dim myPath As String, myFN As String
'
myPath = "\\193.43.114.144\shares\Divisione Buitoni\Supply Chain\Demand&Supply Planning\Business Position & Supply Issues Monitor BUITONI\SUPPLY ISSUES MONITOR\prova Andrea\storico chilled SIM\"
myFN = "SIM" & Format(Now, "dd-mm-yyyy") & ".xlsx" '??? L'estensione l'ho inventata
'Apro il file giornaliero:
Application.EnableEvents = False
Workbooks.Open myPath & myFN, 0
'Salvo il FOGLIO da inviare:
Sheets("Foglio1").Copy '??? Il nome del foglio da inviare me lo sono inventato
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Environ("Temp") & "\FileAllegato.xlsx" '??? Anche qui l'estensione l'ho inventata
'Chiudo il file da allegare
ActiveWorkbook.Close False
'Chiudo il file giornaliero:
Workbooks(myFN).Close False
Application.DisplayAlerts = True
'DA QUI SI CREA LA MAIL:
Set OutApp = CreateObject("Outlook.Application")
EmailAddr = "TuaEmail@Dominiozczc.Com" '<<< INDIRIZZO EMAIL
Subj = "Un Soggetto a piacere" '<<< OGGETTO DELLA MAIL
Set OutMail = OutApp.CreateItem(0)
With OutMail
.body = "Caro amico ti scrivo" & vbCrLf & "Cordiali saluti" '<<< Un piccolo teesto?
.to = EmailAddr
.CC = "altro@altro.cc" '<<<
.BCC = "unaltr@unaltro.cz" '<<<
.Subject = Subj
.Attachments.Add Environ("Temp") & "\FileAllegato.xlsx" ''??? Sempre estensione inventata
.display 'or use .send
End With
' (c)
Set OutMail = Nothing
' (d)
Set OutApp = Nothing
'
End Sub
Sub Invioemail_FoglioAllegato()
Dim OutApp As Object, OutMail As Object
Dim EmailAddr As String, Subj As String
Dim myPath As String, myFN1 As String, myFN As String
'
myPath = "\\193.43.114.144\shares\Divisione Buitoni\Supply Chain\Demand&Supply Planning\Business Position & Supply Issues Monitor BUITONI\SUPPLY ISSUES MONITOR\prova Andrea\storico chilled SIM\ "
myFN1 = "SIM"
myFN = myFN1 & " " & Format(Now, "dd-mm-yyyy") & ".xlsm"
'Apro il file giornaliero:
Application.EnableEvents = False
Workbooks.Open myPath & myFN, 1
'Salvo il FOGLIO da inviare:
Sheets("INVIO").Copy
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Environ("Temp") & "\FileAllegato.xlsm"
'Chiudo il file da allegare
ActiveWorkbook.Close False
'Chiudo il file giornaliero:
Workbooks(myFN).Close False
Application.DisplayAlerts = True
'DA QUI SI CREA LA MAIL:
Set OutApp = CreateObject("Outlook.Application")
EmailAddr = "tav@dominio.com" '<<< INDIRIZZO EMAIL
Subj = "Mio SIM" '<<< OGGETTO DELLA MAIL
Set OutMail = OutApp.CreateItem(0)
With OutMail
.body = "Buongiorno a tutti," & vbCrLf & "di seguito il Supply Issue Monitor di oggi." vbCrLf "A disposizioni per chiarimenti"
.to = EmailAddr
'.CC = "altro@altro.cc" '<<<
'.BCC = "unaltr@unaltro.cz" '<<<
.Subject = Subj
.Attachments.Add Environ("Temp") & "\FileAllegato.xlsm"
.display 'or use .send
End With
' (c)
Set OutMail = Nothing
' (d)
Set OutApp = Nothing
'
End Sub
Range("IndirizzoCella").Value
EmailAddr = Range("G8").Value
Function All_Adr(ByRef CollAdd As Range) As String
Dim oCell As Range, eAdr
'
For Each oCell In CollAdd
If oCell <> "" Then
eAdr = eAdr & "; " & oCell
Else
Exit For
End If
Next oCell
All_Adr = Mid(eAdr, 3)
End Function
'Creazione mail:
Set OutApp = CreateObject("Outlook.Application")
''EmailAddr = "tav@dominio.com" '<<< INDIRIZZO EMAIL
Subj = "SIM Buitoni" '<<< OGGETTO DELLA MAIL
Set OutMail = OutApp.CreateItem(0)
With OutMail
.body = "Buongiorno a tutti," & Chr(10) & _
Chr(10) & "di seguito il Supply Issue Monitor di oggi."
'' Sheets("Elenco").Select
'' EmailAddr = Range("A1:A999").Value
'' CopyCC = Range("B1;B99").Value
.to = All_Adr(Sheets("Elenco").Range("A1:A200"))
.CC = All_Adr(Sheets("Elenco").Range("B1:B200"))
.Subject = Subj
.Attachments.Add Environ("Temp") & "\FileAllegato.xlsx"
.display 'or use .send
End With
Torna a Applicazioni Office Windows
Macro modifica date scelta periodo Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 11 |
Inserire dati filtrati da 2 file ad un terzo file Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 14 |
Supporto per sviluppo macro VBA Ordinare per data Autore: Carletto Ribolla |
Forum: Applicazioni Office Windows Risposte: 3 |
Visitano il forum: Nessuno e 47 ospiti