I Have a Excel Workbook with a Userform.
On The Form is a textbox where the user fills in
an Email adress. When Pressing Ok-Button
the email adress is transverted to the outlook recipient
field.
My Question is the part of code to get the adress from the textbox to the code for filling the mailform.
Code So Far:
Dim sFileName As String
Dim sRecip As String
Private Sub anulerenbtn_Click()
Unload Form1
End Sub
Private Sub okbtn_Click()
On Error GoTo Err_okbtn_Click
Dim objOL As New Outlook.Application
Dim objMail As MailItem
Set objOL = New Outlook.Application
Set objMail = objOL.CreateItem(olMailItem)
sFileName = Application.GetSaveAsFilename( _
fileFilter:="Excel Files (*.xls), *.xls"
Select Case sFileName
Case sFileName = "False"
Exit Sub
Case sFileName = "True"
GoSub Mail
End Select
Mail:
With objMail
.To = sRecip
.CC = "Hans Zwennes"
.Subject = "Probleemhoek Formulier" & " " & Date
.Body = "Dit Is een Test"
.Display
.Attachments.Add sFileName
End With
Exit_okbtn_Click:
Set objMail = Nothing
Set objOL = Nothing
Exit Sub
Err_okbtn_Click:
MsgBox Err.Description
Resume Exit_okbtn_Click
End Sub
Thanks,
On The Form is a textbox where the user fills in
an Email adress. When Pressing Ok-Button
the email adress is transverted to the outlook recipient
field.
My Question is the part of code to get the adress from the textbox to the code for filling the mailform.
Code So Far:
Dim sFileName As String
Dim sRecip As String
Private Sub anulerenbtn_Click()
Unload Form1
End Sub
Private Sub okbtn_Click()
On Error GoTo Err_okbtn_Click
Dim objOL As New Outlook.Application
Dim objMail As MailItem
Set objOL = New Outlook.Application
Set objMail = objOL.CreateItem(olMailItem)
sFileName = Application.GetSaveAsFilename( _
fileFilter:="Excel Files (*.xls), *.xls"
Select Case sFileName
Case sFileName = "False"
Exit Sub
Case sFileName = "True"
GoSub Mail
End Select
Mail:
With objMail
.To = sRecip
.CC = "Hans Zwennes"
.Subject = "Probleemhoek Formulier" & " " & Date
.Body = "Dit Is een Test"
.Display
.Attachments.Add sFileName
End With
Exit_okbtn_Click:
Set objMail = Nothing
Set objOL = Nothing
Exit Sub
Err_okbtn_Click:
MsgBox Err.Description
Resume Exit_okbtn_Click
End Sub
Thanks,