Senden Sie E-Mail über MailEnvelope (VBA, Excel)

Möchte ich ein makro erstellen, kopiert einen bestimmten Bereich in outlook (mit Bildern). Aber es funktioniert nicht wie ich es mir vorstelle...

Sub Send_Range_Or_Whole_Worksheet_with_MailEnvelope()
'Working in Excel 2002-2016
Dim AWorksheet As Worksheet
Dim Sendrng As Range
Dim rng As Range

On Error GoTo StopMacro

With Application
    .ScreenUpdating = False
    .EnableEvents = False
End With

'Fill in the Worksheet/range you want to mail
'Note: if you use one cell it will send the whole worksheet
Set Sendrng = Worksheets("EMAIL").Range("B2:W41")

'Remember the activesheet
Set AWorksheet = ActiveSheet

With Sendrng

    ' Select the worksheet with the range you want to send
    .Parent.Select

    'Remember the ActiveCell on that worksheet
    Set rng = ActiveCell

    'Select the range you want to mail
    .Select

    ' Create the mail and send it
    ActiveWorkbook.EnvelopeVisible = True
    With .Parent.MailEnvelope

        ' Set the optional introduction field thats adds
        ' some header text to the email body.
        .Introduction = "This is test mail 2."

        With .Item
            .To = ThisWorkbook.Sheets("EMAIL").Range("Z1").Value
            .CC = ThisWorkbook.Sheets("EMAIL").Range("Z1").Value
            .BCC = ""
            .Subject = ThisWorkbook.Sheets("EMAIL").Range("D1").Value
            .Display
        End With

    End With

    'select the original ActiveCell
    rng.Select
End With

'Activate the sheet that was active before you run the macro
AWorksheet.Select

StopMacro:
With Application
    .ScreenUpdating = True
    .EnableEvents = True
End With
ActiveWorkbook.EnvelopeVisible = False

End Sub

Kann mir bitte jemand sagen, warum MailEnvelope ist die Anzeige nur für 1 Sekunde und nichts passiert danach? So wie es scheint nicht für mich arbeiten.

Habe ich ersetzt .senden Sie mit .Anzeige aber noch nichts verpasst. Alternativ habe ich versucht zu verwenden, die RNGtoHTML code, aber dieser code funktioniert nicht, kopieren Sie die Bilder (ich habe dynamisch verknüpfte Bild in der Tabelle "E-MAIL").

InformationsquelleAutor Bluesector | 2017-04-07

Schreibe einen Kommentar