Live-Forum - Die aktuellen Beiträge
Datum
Titel
17.04.2024 18:57:33
17.04.2024 16:56:58
Anzeige
Archiv - Navigation
1668to1672
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Excel Bereich per Mail versenden - Signature fehlt

Excel Bereich per Mail versenden - Signature fehlt
24.01.2019 16:34:18
Heidi
Hallo zusammen,
vielleicht kann mir jemand helfen. Ich möchte gerne in Excel einen bestimmten Bereich per Mail versenden. Der Code funktioniert gut, leider aber ohne Outlook-Signature.
Hier der Code:
Sub Send_OriginalRange_from_Excel()
'Getestet unter Office XP
'Ohne Select geht es nicht :-))
Range("A1:I70").Select
'Das anzeigen der Envelope Commandbar ist unabdingbar
ActiveWorkbook.EnvelopeVisible = True
'Nun werden die Adressen vergeben
With ActiveSheet.MailEnvelope
.Introduction = "Guten Tag"
.Item.To = "max.mustermann@siemens.com ; PM BLN, Prim. Eng. Bearbeiter ERL, Prim. Eng.  _
Bearbeiter BLN, Sec. Eng. Bearbeiter ERL; PM BLN; Sec. Eng. Bearbeiter BLN "
.Item.CC = "max.mustermann@siemens.com "
.Item.Subject = "Kick-off: 8Dxx-x - project name / country - LIPROGIS XXXX"
.Item.Send
End With
End Sub
Vielen lieben Dank schon Mal.

6
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Excel Bereich per Mail versenden - Signature fehlt
24.01.2019 17:14:52
Herbert
Hallo Heidi,
ich weiß nicht, ob hier noch jemand mit OfficeXP arbeitet und ob mein Vorschlag unter OXP funktioniert, deshalb kann ich es nur mal unter Vorbehalt versuchen!
Sub MailViaOutlook()
Dim rng As Range, olApp As Object
On Error Resume Next
Set rng = Range("A1:I70")
Set olApp = CreateObject("Outlook.Application")
With olApp.CreateItem(0)
Application.ScreenUpdating = False
.Subject = "Kick-off: 8Dxx-x - project name / country - LIPROGIS XXXX"
.To = "max.mustermann@siemens.com ; PM BLN, Prim. Eng. Bearbeiter ERL, Prim. Eng. _
Bearbeiter BLN, Sec. Eng. Bearbeiter ERL; PM BLN; Sec. Eng. Bearbeiter BLN "
.cc = "max.mustermann@siemens.com"
.HTMLBody = RangetoHTML(rng)
.send
End With
Application.ScreenUpdating = True
Set olApp = Nothing
Set rng = Nothing
End Sub
Servus
Anzeige
AW: Excel Bereich per Mail versenden - Signature fehlt
24.01.2019 18:37:17
Heidi
Hallo,
leider hat es nicht funktioniert. Gibt es vielleicht noch eine andere Möglichkeit?
Dankeschön :-)
AW: Ich auch nicht! owt
24.01.2019 18:39:02
Herbert
,,
AW: Excel Bereich per Mail versenden - Signature fehlt
24.01.2019 18:59:44
Heidi
Ich glaube ich habe eine Code gefunden, leider kriege ich in diesem Code keinen bestimmten Bereich rein. Ich möchte ja ur einen bestimmten Excelbereich versenden.
Vielleicht kann hier jemand helfen. DANKE
Sub Mail_Outlook_With_Signature_Html_1()
' Working in Office 2000-2016
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "

Dear Customer Ron de Bruin

" & _ "Please visit this website to download the new version.
" & _ "Let me know if you have problems.
" & _ "Ron's Excel Page" & _ "
Thank you" On Error Resume Next With OutMail .Display .To = "max.muster@musterman" .CC = "" .BCC = "" .Subject = "This is the Subject line" .HTMLBody = strbody & "
" & .HTMLBody .Send End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing End Sub

Anzeige
AW: Excel Bereich per Mail versenden - Signature fehlt
24.01.2019 19:52:45
Heidi
Hallo nochmal,
bräuchte dringend eine Lösung für das Makro. Wir brauchen dringend eine automatisch Outlook Signature. Dankeschön.
AW: Excel Bereich per Mail versenden - Signature fehlt
25.01.2019 09:58:06
PeterK
Hallo Heidi
Da schon auf Ron's Seite warst, hier der komplette Code (inkl. RangeToHtml :-)
Sub Mail_Selection_Range_Outlook_Body()

    Dim rng As Range
    Dim OutApp As Object
    Dim OutMail As Object
    Dim signature As String
    
    Set rng = Nothing
    On Error Resume Next

    Set rng = Selection.SpecialCells(xlCellTypeVisible)
    'You can also use a fixed range if you want 
    'Set rng = Worksheets("Tabelle1").Range("A1:C6").SpecialCells(xlCellTypeVisible) 
    On Error GoTo 0

    If rng Is Nothing Then
        MsgBox "The selection is not a range or the sheet is protected" & _
               vbNewLine & "please correct and try again.", vbOKOnly
        Exit Sub
    End If

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

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
        .display
        signature = .HTMLBody
        .To = "a.b@c.com"
        .CC = ""
        .BCC = ""
        .Subject = "This is the Subject line"
        .HTMLBody = RangetoHTML(rng) & "<br>" & signature
        .Send   'or use .Display 
    End With
    On Error GoTo 0

    With Application
        .EnableEvents = True
        .ScreenUpdating = True
    End With

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub


Function RangetoHTML(rng As Range)
' Changed by Ron de Bruin 28-Oct-2006 
' Working in Office 2000-2016 
    Dim fso As Object
    Dim ts As Object
    Dim TempFile As String
    Dim TempWB As Workbook

    TempFile = Environ$("temp") & "\" & Format(Now, "dd-mm-yy h-mm-ss") & ".htm"

    'Copy the range and create a new workbook to past the data in 
    rng.Copy
    Set TempWB = Workbooks.Add(1)
    With TempWB.Sheets(1)
        .Cells(1).PasteSpecial Paste:=8
        .Cells(1).PasteSpecial xlPasteValues, , False, False
        .Cells(1).PasteSpecial xlPasteFormats, , False, False
        .Cells(1).Select
        Application.CutCopyMode = False
        On Error Resume Next
        .DrawingObjects.Visible = True
        .DrawingObjects.Delete
        On Error GoTo 0
    End With

    'Publish the sheet to a htm file 
    With TempWB.PublishObjects.Add( _
         SourceType:=xlSourceRange, _
         Filename:=TempFile, _
         Sheet:=TempWB.Sheets(1).Name, _
         Source:=TempWB.Sheets(1).UsedRange.Address, _
         HtmlType:=xlHtmlStatic)
        .Publish (True)
    End With

    'Read all data from the htm file into RangetoHTML 
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2)
    RangetoHTML = ts.readall
    ts.Close
    RangetoHTML = Replace(RangetoHTML, "align=center x:publishsource=", _
                          "align=left x:publishsource=")

    'Close TempWB 
    TempWB.Close savechanges:=False

    'Delete the htm file we used in this function 
    Kill TempFile

    Set ts = Nothing
    Set fso = Nothing
    Set TempWB = Nothing
End Function

VBA/HTML-CodeConverter, AddIn für Office 2002-2016 - in VBA geschrieben von Lukas Mosimann. Projektbetreuung:RMH Software & Media

Code erstellt und getestet in Office 15 - mit VBAHTML 12.6.0


Anzeige

319 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige