ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   TextBox Values to Outlook (https://www.excelbanter.com/excel-programming/379856-re-textbox-values-outlook.html)

[email protected]

TextBox Values to Outlook
 
Hi
Add it to the message
ProjName = Userform1.txbProjName.Value
Unload Userform1
'more code
strbody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"This is line 4" & vbNewLine & _
"Project name is " & ProjName
'more code

regards
Paul

PW11111 wrote:

Hi,

Can I amend the following code so it inserts the values from a tex tbox on a
userform into an outlook message.

For example I have a textbox - txbProjName on my userform that shows the
projects full name.

Any help would be great.

Sub Mail_small_Text_Outlook()
' Is working in Office 2000-2007
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String

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

strbody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"This is line 4"

On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "WorkPlace Strategy: Executive Summery"
.Body = strbody
.Display 'or use .Send
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing
End Sub




All times are GMT +1. The time now is 12:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com