Outlook VBA für das senden von E-Mails mit attachment
Muss ich senden fast 100 E-Mails an einem Tag zu unterschiedlichen Menschen mit unterschiedlichen Dateinamen. Der code unten funktioniert völlig in Ordnung, aber das problem ist, dass die Dateien, die ich beifügen sollte datiert werden eines Tages Vorherige. Zum Beispiel das Datum von heute ist der 7. März 2013 (7-03-13). Ich bekomme die Dateien RN2425 06-03-13.xls und diese ändern sich jeden Tag. Ich möchte die lookup-der einen Tag früheren Dateien in bestimmten Verzeichnis D:\Reporting\Daily\RN2425\RN2425 (ein Tag früheren Zeitstempel).xls
Bitte helfen Sie mir mit diesem code die ich brauche, um das Datum in den Dateinamen. Ich will, dass das automatisch gemacht werden.
Sub CreateEmail(Subject As String, Body As String, ToSend As String, CCs As String, FilePathtoAdd As String)
'write the default Outlook contact name list to the active worksheet
Dim OlApp As Object
Dim OlMail As MailItem
Dim ToRecipient As Variant
Dim CcRecipient As Variant
'Set OlApp = CreateObject("Outlook.Application")
'Set OlMail = OlApp.CreateItem(olMailItem)
Set OlApp = Application
Set OlMail = OlApp.CreateItem(olMailItem)
'For Each ToRecipient In Array("[email protected]", "[email protected]", "[email protected]")
'OlMail.Recipients.Add ToRecipient
OlMail.Recipients.Add ToSend
'Next ToRecipient
'For Each CcRecipient In Array("[email protected]", "[email protected]", "[email protected]")
'With OlMail.Recipients.Add(CcRecipient)
'.Type = 2
'End With
'Next CcRecipient
Dim Temp As Recipient
Set Temp = OlMail.Recipients.Add(CCs)
Temp.Type = olCC
'fill in Subject field
OlMail.Subject = Subject
OlMail.Body = Body
'Add the active workbook as an attachment
' OlMail.Attachments.Add "C:\Users\Ali\Desktop\Sentence Correction\Comparisons.pdf"
If FilePathtoAdd <> "" Then
OlMail.Attachments.Add FilePathtoAdd
End If
'Display the message
OlMail.Display 'change this to OlMail.Send if you just want to send it without previewing it
End Sub
Sub EmailIt()
CreateEmail "This is Subject", "Body", "[email protected], [email protected]", "[email protected], [email protected]", "E:\Ali's Documents\RN2425 06-03-13.xls"
CreateEmail "This is Subject", "Body", "[email protected], [email protected]", "[email protected], [email protected]", "E:\Ali's Documents\RN2425 06-03-13.xls"
CreateEmail "This is Subject", "Body", "[email protected], [email protected]", "[email protected], [email protected]", "E:\Ali's Documents\RN2425 06-03-13.xls"
CreateEmail "This is Subject", "Body", "[email protected], [email protected]", "[email protected], [email protected]", "E:\Ali's Documents\RN2425 06-03-13.xls"
CreateEmail "This is Subject", "Body", "[email protected], [email protected]", "[email protected], [email protected]", "E:\Ali's Documents\RN2425 06-03-13.xls"
CreateEmail "This is Subject", "Body", "[email protected], [email protected]", "[email protected], [email protected]", "E:\Ali's Documents\AVSEQ03 Comp 1.avi"
End Sub
InformationsquelleAutor user2145517 | 2013-03-07
Du musst angemeldet sein, um einen Kommentar abzugeben.
Um das heutige Datum in das richtige format:
Bekommen yesterdays Datum:
Alles zusammen:
InformationsquelleAutor niton