Hi
First time poster here.
I've been struggling with this for days now and would really appreciate some help with it.
I have a limited knowledge of VBA and have cobbled together the macro below, which attaches the current Word doc to an email template, populates the Subject field and inserts text at two bookmarks in the body of the email. This works ok, but it means that the user has to fill in two separate InputBox text fields that pop up one after the other.
What I really want to do is replace these with a single Userform with two text fields for Client Name and Client Reference. I just can't seem to find the code to enter the name and reference number at the the bookmarks.
Any help would be much appreciated.
Thanks
Neil
Sub Email_SO_mandate()
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oitem As Outlook.MailItem
On Error Resume Next
ActiveDocument.SaveAs FileName:="H:\Email templates\Standing order mandate"
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
Set oitem = oOutlookApp.CreateItemFromTemplate("H:\Email templates\SO mandate email template.oft")
With oitem
.To = ""
.Subject = "Standing Order Mandate"
'Add the document as an attachment, you can use the .displayname property
'to set the description that's used in the message
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
DisplayName:="Document as attachment"
strMgrName = InputBox("Client's Name (first name, or title & surname)")
oitem.HTMLBody = Replace(oitem.HTMLBody, "client_name", strMgrName)
strMgrName = InputBox("Client's Reference Nunber")
oitem.HTMLBody = Replace(oitem.HTMLBody, "ref_no1", strMgrName)
oitem.HTMLBody = Replace(oitem.HTMLBody, "ref_no2", strMgrName)
oitem.Display
.Display
End With
Set oitem = Nothing
Set oOutlookApp = Nothing
End Sub