JosEindhoven
Gebruiker
- Lid geworden
- 4 dec 2014
- Berichten
- 431
Goede morgen
In een bestand zit een button op het tabblad gegevens om blanco mail te versturen naar emailontvangers. De ontvangers haalt hij uit het tabblad test. De verzending gaat via outlook. Ik krijg het maar niet voor elkaar om dit via gmail te doen. Heeft er iemand een oplossing voor de code
Private Sub CommandButton4_Click()
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim Sourcewb As Workbook
Dim Destwb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim OutApp As Object
Dim OutMail As Object
Dim strto As String
Dim strbody As String
Dim cell As Range
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set Sourcewb = ActiveWorkbook
Set Destwb = ActiveWorkbook
With Destwb
FileExtStr = ".xlsx": FileFormatNum = 51
End With
TempFilePath = Environ$("temp") & ""
TempFileName = ""
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
For Each cell In ThisWorkbook.Sheets("Test").Range("i1:i450")
If cell.Value Like "?*@?*.?*" Then
If strto = "" Then strto = stro & ";"
strto = strto & cell.Value & ";"
End If
Next cell
.To = ""
.CC = ""
.BCC = strto
.Subject = ""
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
In een bestand zit een button op het tabblad gegevens om blanco mail te versturen naar emailontvangers. De ontvangers haalt hij uit het tabblad test. De verzending gaat via outlook. Ik krijg het maar niet voor elkaar om dit via gmail te doen. Heeft er iemand een oplossing voor de code
Private Sub CommandButton4_Click()
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim Sourcewb As Workbook
Dim Destwb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim OutApp As Object
Dim OutMail As Object
Dim strto As String
Dim strbody As String
Dim cell As Range
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set Sourcewb = ActiveWorkbook
Set Destwb = ActiveWorkbook
With Destwb
FileExtStr = ".xlsx": FileFormatNum = 51
End With
TempFilePath = Environ$("temp") & ""
TempFileName = ""
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
For Each cell In ThisWorkbook.Sheets("Test").Range("i1:i450")
If cell.Value Like "?*@?*.?*" Then
If strto = "" Then strto = stro & ";"
strto = strto & cell.Value & ";"
End If
Next cell
.To = ""
.CC = ""
.BCC = strto
.Subject = ""
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub