Create Outlook Task from Template and append Body with Email Body

Post number 2 has been selected as the best answer.

STiGuy04

Member
OS Version(s)
  1. Windows
Outlook version
Outlook 365 64 bit
Email Account
Office 365 Exchange
Operating system::    Windows
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
 
>> objtask.Body = objMail.RTFBody

you need to use
objtask.Body = objtask.body & objMail.RTFBody

might need a vbcrlf or two in between
objtask.body & vbcrlf & objMail.RTFBody
 
>> objtask.Body = objMail.RTFBody

you need to use
objtask.Body = objtask.body & objMail.RTFBody

might need a vbcrlf or two in between
objtask.body & vbcrlf & objMail.RTFBody
I will give this a shot and report back. Thank you!
 
>> objtask.Body = objMail.RTFBody

you need to use
objtask.Body = objtask.body & objMail.RTFBody

might need a vbcrlf or two in between
objtask.body & vbcrlf & objMail.RTFBody
ok so that gets me closer, however, the objMail.RTFBody section of the stuff being brought in turned into asian fonts it looks like. The upper body of the task has my template and then below is asian fonts assuming it is some sort of corrupted or mistranslated text from the body from the email.
 
figured it out. It was the RTFBody that was screwing it up. I just changed it to objMail.Body and it pulled through just fine. I don't know VBA well so just trying different things till it works.
 
Similar threads
Thread starter Title Forum Replies Date
J Create new outlook task into task subfolder using vba Using Outlook 6
J PSA: How to create custom keyboard shortcut for "Paste Unformatted Text" in Outlook on Windows Outlook VBA and Custom Forms 1
Commodore Any way to create "from-only" account on Outlook 2021? Using Outlook 1
N Can't create NEW GROUP and add/remove a member from existing Group in Outlook Using Outlook 1
O Outlook 365 - How to create / copy a new contact from an existing one? Using Outlook 5
G Can't create Folder Groups in Outlook 2013 Using Outlook 0
N Outlook rules don't create a copy for bcc'ed emails Using Outlook 3
F Delete/create/reset Exchange mailbox on Outlook.com Using Outlook.com accounts in Outlook 3
R Can not create folder to store specific emails in in Outlook for Mac Using Outlook 1
A Outlook macro to create search folder with mail categories as criteria Outlook VBA and Custom Forms 3
Rupert Dragwater How to create a new email with @outlook.com Using Outlook.com accounts in Outlook 32
D create an html table in outlook custom form 2010 using vba in MsAccess Outlook VBA and Custom Forms 7
R Outlook add-in to create new contact from an email. Using Outlook 0
Tanja Östrand Outlook 2016 - Create Macro button to add text in Subject Outlook VBA and Custom Forms 1
D Outlook macros to create meeting on shared calendar Outlook VBA and Custom Forms 10
G How do I create a custom pick list in VB for an outlook automated email? Outlook VBA and Custom Forms 1
Diane Poremsky Create a custom field for Outlook messages Using Outlook 0
Diane Poremsky Create a Custom Numbering Field for Outlook messages Using Outlook 0
Diane Poremsky Manually create a POP3 account in Outlook 2007 Using Outlook 0
T Create Rule For Secondary E-Mail Address In Outlook 2016 Using Outlook 4
Diane Poremsky Use VBA to create an Outlook Search Folder for Sender Using Outlook 0
Diane Poremsky Create an Outlook appointment from an email message Using Outlook 4
Diane Poremsky Outlook Crashes When You Reply or Create a New Message Using Outlook 0
I Create custom Outlook 2013 Rule in Office 365 Outlook VBA and Custom Forms 5
C Edit/Create Pen Not Working Outlook 2013 Using Outlook 1
Rupert Dragwater Outlook could not create the work file Using Outlook 5
J Outlook Rule - Create Link in Forwarding Message Outlook VBA and Custom Forms 2
E Create a URL hyperlink in an Outlook custom form? Outlook VBA and Custom Forms 2
R iCloud Issues in Outlook 2013, cannot create reminders Using Outlook 2
Rupert Dragwater How to delete old rules and create new in Outlook 2013 Using Outlook 12
P Cannot open Options Menu Outlook 2007 and Cannot create a new profile Using Outlook 0
C Outlook 2007 cant create new account Using Outlook 7
G Outlook could not create the work file Using Outlook 0
K Outlook Cached Mode - can't create rules to move email to another mailbox Using Outlook 2
O Can't create new email or access email acounts Outlook 2003 Using Outlook 1
S [outlook-users] Create contact group from other user's contacts Using Outlook 1
L Create hyperlinks to bookmarks in Outlook 2003 otf file Using Outlook 1
B How do I create and send mail in Outlook 2003 from code? Using Outlook 5
O Outlook 2010 - How to create custom Group By Arrangements for email Using Outlook 3
R Outlook 2007 attachments create multiple copies in the inbox Using Outlook 3
J Create or Import a Outlook Rule through C# code. Outlook VBA and Custom Forms 2
F can I use Outlook 2007 to create peer review/approve/reject forms Outlook VBA and Custom Forms 1
E Outlook could not create the work file. Check the temp environment variable Using Outlook 8
S Create a new Outlook MailItem in an Outlook folder(not a draft) Outlook VBA and Custom Forms 2
D Create a macro in Outlook to run a rule Outlook VBA and Custom Forms 32
B How to create the customized Outlook SQL DASL for selected days? Outlook VBA and Custom Forms 2
N How Can I create an Outlook Macro to import calendar? Outlook VBA and Custom Forms 1
P Create appointment to custom (shared) outlook calendar Outlook VBA and Custom Forms 3
S HELP: Create Buttons in Outlook Email body or Tool bar Outlook VBA and Custom Forms 1
N How to create hidden rule in outlook 2007 Outlook VBA and Custom Forms 3

Similar threads

Back
Top