Dowsey1977
10-11-2005, 04:47 AM
Hi,
I am using the below code to send an email with pre-populated recipients, subject and password protection. I want to add in the body text as well, but can't figure out a good way of doing it. The SendMail desn't allow for this, and I've tried all sorts of stuff with CreateObject, but can't figure all this out.
Private Sub CommandButton1_Click()
Dim Rcpts(1 To 3) As String
Dim Name, Password As String
Application.ScreenUpdating = False
If txtPassword.Value = "" Then
MsgBox "A password must be entered for Form 6 to be sent", vbCritical, "Password Entry Error"
Else
Unload Me 'Gers rid of the userform
Name = "Form 6 Cash Processing Request - " & Range("D97").Value 'Subject Of email (Range 97 Value is transaction type)
Password = txtPassword.Value 'This is the textbox on the userform
ThisWorkbook.SaveAs FileName:=Name, Password:=Password 'Saves the workbook with Name and Password
Rcpts(1) = "simon.dowse@Domain.com" 'Recipient email adress
Rcpts(2) = ""
Rcpts(3) = ""
ThisWorkbook.SendMail Recipients:=Rcpts, Subject:=Name, ReturnReceipt:=True 'Details on email
MsgBox "The report has now been emailed to Cash Processing for action " & Application.UserName 'Messagebox confirming send
End If
Application.ScreenUpdating = True
End Sub
Any ideas??
:motz2: :bow:
I am using the below code to send an email with pre-populated recipients, subject and password protection. I want to add in the body text as well, but can't figure out a good way of doing it. The SendMail desn't allow for this, and I've tried all sorts of stuff with CreateObject, but can't figure all this out.
Private Sub CommandButton1_Click()
Dim Rcpts(1 To 3) As String
Dim Name, Password As String
Application.ScreenUpdating = False
If txtPassword.Value = "" Then
MsgBox "A password must be entered for Form 6 to be sent", vbCritical, "Password Entry Error"
Else
Unload Me 'Gers rid of the userform
Name = "Form 6 Cash Processing Request - " & Range("D97").Value 'Subject Of email (Range 97 Value is transaction type)
Password = txtPassword.Value 'This is the textbox on the userform
ThisWorkbook.SaveAs FileName:=Name, Password:=Password 'Saves the workbook with Name and Password
Rcpts(1) = "simon.dowse@Domain.com" 'Recipient email adress
Rcpts(2) = ""
Rcpts(3) = ""
ThisWorkbook.SendMail Recipients:=Rcpts, Subject:=Name, ReturnReceipt:=True 'Details on email
MsgBox "The report has now been emailed to Cash Processing for action " & Application.UserName 'Messagebox confirming send
End If
Application.ScreenUpdating = True
End Sub
Any ideas??
:motz2: :bow: