Ich habe einige Makros und Taskplaner, die: Excel zu einem bestimmten Zeitpunkt starten, einige Tabellen aktualisieren, erstellen Sie PDF-Dokumente aus diesen Tabellen und dann per E-Mail diese PDF-Dokumente Wählen Sie Einzelpersonen.E-Mail gesendet über VBA mit Taskplaner wird im Postausgang blockiert
Alles läuft bis zur Erstellung eines PDF-Dokuments und E-Mail. Manchmal bleibt diese E-Mail jedoch im Postausgang hängen und wird erst gesendet, wenn ich Outlook öffne.
Weiß jemand die Ursache für dieses Problem? Hier
ist der Code für das Senden der E-Mail:
Option Explicit
Public strFileName As String
Sub EmailPDFAsAttachment()
'This macro grabs the file path and stores as a concatenation/variable. Then it emails the file to whomever you specify.
' Works in Excel 2000, Excel 2002, Excel 2003, Excel 2007, Excel 2010, Outlook 2000, Outlook 2002, Outlook 2003, Outlook 2007, Outlook 2010.
' This example sends the last saved version of the Activeworkbook object .
Dim OutApp As Object
Dim OutMail As Object
Dim FilePath As String
'This part is setting the strings and objects to be files to grab with their associated filepath. (e.g. FilePath is setting itself equal to the text where we plan to set up each report)
FilePath = "\\"ServerNameHere"\UserFolders\_AutoRep\DA\PDFs\SealantsVS1SurfaceRestore\" _
& strFileName & ".pdf"
With Application
.EnableEvents = True
.ScreenUpdating = True
' End With
'Below is where it creats the actual email and opens up outlook.
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
' ******Make sure to set the .To to only recipients that are required to view it. Separate email addresses with a semicolon (;).
' Current distribution list:
'
With OutMail
.To = "[email protected]"
.CC = ""
.BCC = ""
.Subject = strFileName
.HTMLBody = "Hello all!" & "<br>" & _
"Here is this month's report for the Sealants vs Surface Restore. It goes as granular as to by show results by provider." & "<br>" & _
"Let me know what you think or any comments or questions you have!" & "<br>" & _
vbNewLine & .HTMLBody
'Here it attached the file, saves the email as a draft, and then sends the file if everything checks out.
.Attachments.Add FilePath
.Send
End With
On Error GoTo 0
' With Application
' .EnableEvents = True
' .ScreenUpdating = True
End With
'This closes out the Outlook application.
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
'After this completes, the Private sub jumps back to the macros in this workbook and quits MS Excel with the CloseWorkbook Application.
Ich habe auch in dem Bild aufgelistet meine Einstellungen unten für meine Tools Referenzbibliothek in Outlook VBA-Einstellungen unter:
Tools Reference Library settings
Und meine Vertrauenseinstellungen:
Makroeinstellungen:
„Alle Makros aktivieren“ ausgewählt
„Makrosicherheitseinstellungen installierten Add-Ins“ ausgewählt
Irgendwelche Ideen, um sie durch den Ausgang Bereich zu schieben, anstatt stecken zu bleiben? Die Idee ist, dieses Programm am frühen Morgen laufen zu lassen und diese E-Mails im Posteingang ausgewählter Personen zu haben, wenn sie zur Arbeit kommen.
'nicht senden, bis ich Outlook öffne' tut [dies] (http://stackoverflow.com/questions/28936757/excel-vba-to-detect-if-outlook-is-open-if-its-its- nicht-dann-öffnen-es) helfen? – findwindow
Nicht sicher, was Sie meinen ..... aber die Idee ist, es senden zu lassen, ohne Outlook zu öffnen. Ich habe einen Aufgabenplaner Öffnen der Excel-Datei, die Datei wird ausgelöst, erstellt die PDF-Datei, erstellt die E-Mail, aber die E-Mail wird im Ordner Outbox gefangen, bis ich Excel öffnen und dann Outlook sendet alles in den Ordner Postausgang I Ich möchte, dass die Datei gesendet wird, ohne dass ich persönlich Outlook geöffnet habe oder Outlook mit dem Taskplaner geöffnet habe. –
'haben es senden, ohne Outlook zu öffnen' das ist wie wollen Sie ein Auto fahren, ohne es zu starten? – findwindow