STiGuy04
Member
- OS Version(s)
- Windows
- Outlook version
- Outlook 365 64 bit
- Email Account
- Office 365 Exchange
Operating system:: Windows
Outlook version: 365
Email type or host: Microsoft 365
Outlook version: 365
Email type or host: Microsoft 365
I have a macro to create a task from an email, but I want to use a template for the base task information including body text. I'm pretty sure when I try to pull in the body of the email it's overwriting my template. How do I preserve that and append my template with the email body? Basically task body first then email body goes below it in the task.
If I remove this line my template pulls in just fine, but of course I'm missing the email body: objtask.Body = objMail.RTFBody
Script below:
Sub NewTask()
Dim objtask As Outlook.TaskItem
Dim objMail As Outlook.MailItem
Set objtask = Application.CreateItemFromTemplate("C:\Program Files (x86)\Microsoft Office\Templates\Template.oft")
For Each objMail In Application.ActiveExplorer.Selection
objtask.Subject = objMail.Subject
objtask.StartDate = objMail.ReceivedTime
objtask.Body = objMail.RTFBody
objtask.Categories = "Category Name"
objtask.Save
objtask.Display
Next
Set objtask = Nothing
Set objMail = Nothing
End Sub
If I remove this line my template pulls in just fine, but of course I'm missing the email body: objtask.Body = objMail.RTFBody
Script below:
Sub NewTask()
Dim objtask As Outlook.TaskItem
Dim objMail As Outlook.MailItem
Set objtask = Application.CreateItemFromTemplate("C:\Program Files (x86)\Microsoft Office\Templates\Template.oft")
For Each objMail In Application.ActiveExplorer.Selection
objtask.Subject = objMail.Subject
objtask.StartDate = objMail.ReceivedTime
objtask.Body = objMail.RTFBody
objtask.Categories = "Category Name"
objtask.Save
objtask.Display
Next
Set objtask = Nothing
Set objMail = Nothing
End Sub