• Privacywetgeving
    Het is bij Helpmij.nl niet toegestaan om persoonsgegevens in een voorbeeld te plaatsen. Alle voorbeelden die persoonsgegevens bevatten zullen zonder opgaaf van reden verwijderd worden. In de vraag zal specifiek vermeld moeten worden dat het om fictieve namen gaat.

Automatisch verzenden

Status
Niet open voor verdere reacties.

RichieL

Gebruiker
Lid geworden
29 nov 2018
Berichten
73
Goedmiddag,

Ik ben bezig met een macro waarmee ik een email vanuit excel maak, maar ik wil graag dat hij automatisch de mail verstuurd ipv dat hij het dialoogscherm open houdt totdat ik op verzenden druk. Is dat mogelijk?

Code:
  ' Use already open Outlook if possible
  On Error Resume Next
  Set OutlApp = GetObject(, "Outlook.Application")
  If Err Then
    Set OutlApp = CreateObject("Outlook.Application")
    IsCreated = True
  End If
  OutlApp.Visible = True
  On Error GoTo 0
 
  ' Prepare e-mail with PDF attachment
  With OutlApp.CreateItem(0)
   
    ' Prepare e-mail
  EmailAddress = Range("F12")
    .Subject = Title
    .To = EmailAddress ' <-- Put email of the recipient here
    .CC = "test@test.nl" ' <-- Put email of 'copy to' recipient here
    .Body = "Hallo," & vbLf & vbLf _
          & "Hierbij de transportopgave" & vbLf & vbLf _
          & "Met vriendelijke groet," & vbLf _
          & Application.UserName & vbLf & vbLf
    .Attachments.Add PdfFile
    
   ' Try to send
    On Error Resume Next
    .Display
    Application.Visible = True
    If Err Then
      MsgBox "E-mail was not sent", vbExclamation
    Else
      MsgBox "E-mail successfully sent", vbInformation
    End If
    On Error GoTo 0
   
  End With
 
  ' Delete PDF file
  Kill PdfFile
 
  ' Quit Outlook if it was created by this code
  If IsCreated Then OutlApp.Quit
 
  ' Release the memory of object variable
  Set OutlApp = Nothing
 
Status
Niet open voor verdere reacties.
Steun Ons

Nieuwste berichten

Terug
Bovenaan Onderaan