Autogenerate eine E-Mail in outlook und fügen Sie die aktuell geöffnete word-Dokument mit VBS
Ich schreiben möchte ein VBS-makro zum automatischen generieren einer E-Mail in outlook und fügen Sie ein word-Dokument. Ich habe momentan ein makro, das dies tut, für excel, aber ich kann nicht damit es funktioniert für Word. Ich kann nicht herausfinden, für das Leben von mir, was mein "FName=" sein sollte. Anregungen oder Hilfe wäre sehr geschätzt werden. Hier ist, was ich habe:
Sub AutoEmail()
On Error GoTo Cancel
Dim Resp As Integer
Resp = MsgBox(prompt:=vbCr & "Yes = Review Email" & vbCr & "No = Immediately Send" & vbCr & "Cancel = Cancel" & vbCr, _
Title:="Review email before sending?", _
Buttons:=3 + 32)
Select Case Resp
'Yes was clicked, user wants to review email first
Case Is = 6
Dim myOutlook As Object
Dim myMailItem As Object
Set otlApp = CreateObject("Outlook.Application")
Set otlNewMail = otlApp.CreateItem(olMailItem)
FName = ActiveWord & "\" & ActiveWord.Name
With otlNewMail
.To = ""
.CC = ""
.Subject = ""
.Body = "Good Morning," & vbCr & vbCr & "" & Format(Date, "MM/DD") & "."
.Attachments.Add FName
.Display
End With
Set otlNewMail = Nothing
Set otlApp = Nothing
Set otlAttach = Nothing
Set otlMess = Nothing
Set otlNSpace = Nothing
'If no is clicked
Case Is = 7
Dim myOutlok As Object
Dim myMailItm As Object
Set otlApp = CreateObject("Outlook.Application")
Set otlNewMail = otlApp.CreateItem(olMailItem)
FName = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name
With otlNewMail
.To = ""
.CC = ""
.Subject = ""
.Body = "Good Morning," & vbCr & vbCr & " " & Format(Date, "MM/DD") & "."
.Attachments.Add FName
.Send
'.Display
'Application.Wait (Now + TimeValue("0:00:01"))
'Application.SendKeys "%s"
End With
'otlApp.Quit
Set otlNewMail = Nothing
Set otlApp = Nothing
Set otlAttach = Nothing
Set otlMess = Nothing
Set otlNSpace = Nothing
'If Cancel is clicked
Case Is = 2
Cancel:
MsgBox prompt:="No Email has been sent.", _
Title:="EMAIL CANCELLED", _
Buttons:=64
End Select
End Sub
InformationsquelleAutor tula132 | 2011-01-12
Du musst angemeldet sein, um einen Kommentar abzugeben.
Vielleicht ist es ein bisschen spät, aber ich möchte es lösen, für die zukünftige Verwendung.
Sie wollen, um das aktive Dokument als Ihr Datei-name (FName).
Können Sie auch wollen, speichern Sie Ihre aktuelle Dokument vor dem senden über outlook, sonst werden Sie senden Sie das Dokument ohne die änderungen.
Ich hoffe, das wird anderen helfen, da der code von der Frage, hat mir sehr geholfen beim scripting ein ähnliches Skript.
InformationsquelleAutor Bloodsaw90