Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1520to1524
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

Empfänger variable in einer Excelliste eintragen

Empfänger variable in einer Excelliste eintragen
26.10.2016 21:36:44
Fabian
Hallo zusammen,
ich habe dieses wunderbare makro gefunden, was auch soweit funktioniert.
Ich wollte fragen ob man die Empfänger so abändern kann das zum beispiel diese Email gesammelt an alle geschickt werden die in Spalte A einer anderen Datei stehen?!
Sub Mail_workbook_Outlook_1()
'Working in Excel 2000-2016
'This example send the last saved version of the Activeworkbook
'For Tips see: http://www. _
rondebruin.nl/win/winmail/Outlook/tips.htm
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.to = "xyz"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
.Attachments.Add ActiveWorkbook.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send   'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Danke für die Hilfe!

7
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Empfänger variable
26.10.2016 21:49:20
Michael
Hallo Fabian,
schau mal hier nach; vielleicht ist es ja was für dein Problem:
https://www.online-vba.de/vba_mailverteilerexcel.php
Gruß
Michael
AW: Empfänger variable
26.10.2016 22:54:04
Anton
Hi,
so vielleicht?
Sub Mail_workbook_Outlook_1()
'Working in Excel 2000-2016
'This example send the last saved version of the Activeworkbook
'For Tips see: http://www.
_
rondebruin.nl/win/winmail/Outlook/tips.htm
Dim OutApp As Object
Dim OutMail As Object
Dim rngEmail As Range
Dim rngZelle As Range
Dim sTo As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Set rngEmail = Workbooks("x").Worksheets("x").Range("x") 'Quelle für Email Range anpassen
For Each rngZelle In rngEmail
sTo = sTo & ";" & rngZelle.Value
Next rngZelle
sTo = Mid(sTo, 2)
On Error Resume Next
With OutMail
.to = "sTo"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
.Attachments.Add ActiveWorkbook.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send   'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub

Anzeige
AW: Empfänger variable
27.10.2016 07:44:24
Fabian
Hi,
das folgende funktioniert für mich sehr gut.
Muss es nur noch schaffen auch den Body, ein Teil der Datei und vielleicht noch 1-2 Dinge variablke zu gestalten =)
Sub Sent_Email()
'Setting up the Excel variables.
Dim olApp As Object
Dim olMailItm As Object
Dim iCounter As Integer
Dim iiCounter As Integer
Dim Dest As Variant
Dim SDest As String
Dim SSDest As String
'Create the Outlook application and the empty email.
Set olApp = CreateObject("Outlook.Application")
Set olMailItm = olApp.CreateItem(0)
'Using the email, add multiple recipients, using a list of addresses in column A.
Worksheets("Sent to").Activate
With olMailItm
SDest = ""
For iCounter = 1 To WorksheetFunction.CountA(Columns(1))
If SDest = "" Then
SDest = Cells(iCounter, 1).Value
Else
SDest = SDest & ";" & Cells(iCounter, 1).Value
End If
Next iCounter
'Using the email, add multiple recipients, using a list of addresses in column A.
SSDest = ""
For iCounter = 1 To WorksheetFunction.CountA(Columns(2))
If SSDest = "" Then
SSDest = Cells(iCounter, 1).Value
Else
SSDest = SSDest & ";" & Cells(iCounter, 1).Value
End If
Next iCounter
'Do additional formatting on the BCC and Subject lines, add the body text from the  _
spreadsheet, and send.
.To = SDest
.cc = SSDest
.Subject = "FYI"
.HTMLBody = "Hallo Meine Damen und Herren, ich wünsche Ihnen einen wunderschönen Guten  _
Abend!" & .HTMLBody
.Attachments.Add ("blabla.xlsx")
.Display
End With
'Clean up the Outlook application.
Set olMailItm = Nothing
Set olApp = Nothing
End Sub

Anzeige
AW: Empfänger variable
27.10.2016 09:21:32
Anton
Guten Morgen Fabian,
das sieht doch gut aus! Brauchst Du dann noch Unterstützung oder schaffst du es alleine?
VG Anton
AW: Empfänger variable
27.10.2016 10:54:14
Fabian
Hi Anton,
im untern Teil habe ich noch .Subject und .HTMLBody mit fixierten Text... wie kann ich das machen das der dort zum bespiel Sheet(xyz) und Cell(b5) nimmt?
Gruß
Fabian
AW: Empfänger variable
27.10.2016 12:46:16
Anton
Hi Fabian,
normal einfach auf die entsprechende Arbeitsmappe + Tabellenblatt + Zelle verweisen.

.Subject = workbooks("Mappe.xlsx").worksheets("xyz").cells(5,2).value
'Hier den Namen der Arbeitsmappe anpassen, mit Dateiendung

.HTMLBody = workbooks("Mappe.xlsx").worksheets("xyz").cells(5,2).value
'Hier den Namen der Arbeitsmappe anpassen, mit Dateiendung
Wenn Du den Namen des Sheets angeben willst dann:

workbooks("Mappe.xlsx").worksheets("xyz").name

Hab jetzt nicht genau gewusst, wo was hin soll.
VG Anton
Anzeige
AW: Empfänger variable
27.10.2016 13:04:35
Fabian
Hallo Anton,
super vielen Dank!
Gruß,
Fabian

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige