I have emails which are created by another system. The BODY of these emails contains the TO, CC, BCC and subject text and at the bottom of the body area there are paths & filenames.
I want to create a macro to place the appropriate information from the body area into the To, cc, Subject fields.
Then use the filepath (or filepaths) which are always at the bottom of the text area to attach the various documents.
Finally, the last filepath/filename is used to “Save as” a pdf.
I have a VERY BASIC start with the code below, (although this creates a new email and I want to work in the exisiting one). I also need a way for the code to find the recipients' addresses and pass them - as variables? - to the ".To" fields etc. Then the attachments and Save As need to be added to this.
Can anyone point me in the right direction please?
Thank you.
Steve
Public Sub CreateNewMessage()
Dim objMsg As MailItem
Set objMsg = Application.CreateItem(olMailItem)
With objMsg
.To = "
A...@abc.com"
.CC = "
x...@xyz.com"
.BCC = "
E...@efg.com"
.Subject = "This is the subject"
.Categories = "Test"
' .VotingOptions = "Yes;No;Maybe;"
.BodyFormat = olFormatPlain ' send plain text message
.Importance = olImportanceNormal
.Sensitivity = olConfidential
.Attachments.Add ("C:\Users\Stephen\Documents\David Tallent\from David Tallent\Ref Letter before any editing.docx")
' Calculate a date using DateAdd or enter an explicit date
' .ExpiryTime = DateAdd("m", 6, Now) '6 months from now
' .DeferredDeliveryTime = #8/1/2012 6:00:00 PM#
.Display
End With
Set objMsg = Nothing
End Sub