bmdo
05-29-2015, 04:51 AM
Hi,
our receptionist sends emails daily to a user as he/she was not available to take a call.
She just types in the subject - like ** Call Peter, from Microsoft, phone +45 22 33 44 55
We want to create a simple macro for her :)
I have the form ready - see attached picture
The code is almost ready :)
Please can you help me to finish it. I am not sure how to insert spaces in the subject, and I cannot get the txtComment.Value into the mail body :(
Please let me know if you need any more info or if some of the code is not correct
Private Sub cmdCancel_Click()
Me.Hide
End Sub
Private Sub cmdSubmit_Click()
Dim oFSO As Object
Dim objOutlook As Outlook.Application
Dim objMail As Outlook.MailItem
Set objMail = Outlook.CreateItem(olMailItem)
strBody = objMail.HTMLBody
'Insert Recipient
objMail.To = txtTo.Value
'Spaces missing
objMail.Subject = "** Ring til" + txtContact.Value + txtOrg.Value + txtPhone.Value
' Set email body format to HTML
objMail.BodyFormat = olFormatHTML
' Doesn't work
objMail.HTMLBody = txtComment.Value
' Insert email text and signatur to email.
objMail.HTMLBody = "<body font-size=11pt>" & sText & strBody & "</body>"
Me.Hide
objMail.Display
Set oFSO = Nothing
Set oFS = Nothing
Set objMail = Nothing
End Sub
Private Sub UserForm_Activate()
txtTo.Value = ""
txtContact.Value = ""
txtOrg.Value = ""
txtPhone.Value = ""
txtComment.Value = ""
End Sub
our receptionist sends emails daily to a user as he/she was not available to take a call.
She just types in the subject - like ** Call Peter, from Microsoft, phone +45 22 33 44 55
We want to create a simple macro for her :)
I have the form ready - see attached picture
The code is almost ready :)
Please can you help me to finish it. I am not sure how to insert spaces in the subject, and I cannot get the txtComment.Value into the mail body :(
Please let me know if you need any more info or if some of the code is not correct
Private Sub cmdCancel_Click()
Me.Hide
End Sub
Private Sub cmdSubmit_Click()
Dim oFSO As Object
Dim objOutlook As Outlook.Application
Dim objMail As Outlook.MailItem
Set objMail = Outlook.CreateItem(olMailItem)
strBody = objMail.HTMLBody
'Insert Recipient
objMail.To = txtTo.Value
'Spaces missing
objMail.Subject = "** Ring til" + txtContact.Value + txtOrg.Value + txtPhone.Value
' Set email body format to HTML
objMail.BodyFormat = olFormatHTML
' Doesn't work
objMail.HTMLBody = txtComment.Value
' Insert email text and signatur to email.
objMail.HTMLBody = "<body font-size=11pt>" & sText & strBody & "</body>"
Me.Hide
objMail.Display
Set oFSO = Nothing
Set oFS = Nothing
Set objMail = Nothing
End Sub
Private Sub UserForm_Activate()
txtTo.Value = ""
txtContact.Value = ""
txtOrg.Value = ""
txtPhone.Value = ""
txtComment.Value = ""
End Sub