Experts Exchange connects you with the people and services you need so you can get back to work.
Dim MyApp As New Word.Application
Dim MyWordDoc As Word.Document = MyApp.Documents.Open("C:\Test\Test.docx")
Open in new window
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
objOutlook = CType(CreateObject("Outlook.Application"), Outlook.Application)
objEmail = objOutlook.CreateItem(Outlook.OlItemType.olMailItem)
Dim body As String
'Gets First word in TextBox
Dim firstWord As String = System.Text.RegularExp<b></b>ressions.Regex.Match(txtContact.Text, "^\w+\b").Value
body = "Hi " & firstWord & "," & vbCrLf & vbCrLf
body += "Please find attached purchase order number " & txtPONumber.Text & "." & vbCrLf & vbCrLf
body += "Please confirm lead time." & vbCrLf & vbCrLf
body += "Thanks and Best Regards," & vbCrLf & cmbBuyer.SelectedItem.ToString
.Subject = "Purchase Order " & txtPONumber.Text
.To = txtEmail.Text
.Body = body
Catch ex As Exception
MsgBox("Unable to generate automatic email. Please create the email manually.", MsgBoxStyle.Information, "Error!")
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.