-
Sep 24th, 2021, 01:32 PM
#1
Thread Starter
Hyperactive Member
Outlook forward item
I currently have some code that forwards the selected item. All works great, and it even adds the default signature.
Code:
Dim newitem as mail item
Dim selecteditems as outlook.selection
Set newitem =selecteditems(i).forward
Newitem.display
This works great, however I want to add some text to the forwarding message, and as soon as I do, it removes all the previous message /txt.
Code:
newitem.body=‘Text to add’
Or
Newitem.body =new.item.body +’text to add’
Both of the above fail to work as required,
Can someone advise how to just add some text to the message leaving all the remaining messages below.
-
Sep 25th, 2021, 02:19 AM
#2
Re: Outlook forward item
Newitem.body =new.item.body +’text to add’
you have an extra . in your message object and you need to use double quotes, should be more like
Code:
Newitem.body =newitem.body & vbnewline & "text to add"
or if it is an HTML email maybe
Code:
Newitem.HTMLbody =newitem.HTMLbody & vbnewline & "text to add"
both untested, and hard to know how your email is formatted
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 25th, 2021, 04:28 AM
#3
Thread Starter
Hyperactive Member
Re: Outlook forward item
I have corrected a few things, and switched to html, however the result was still the same. Further investigation indicated that using the + sign to concatenate the strings rather than the & was causing the problem.
The only problem now is that when I concatenate the string, the vbNew!ine is ignored. When the string is added to newitem.htmlbody. I have also tried vbCrLf.
If you add the string together first into one master string, it adds the line feed in ok, but as soon as you add the master string to newitem.htmlbody it is removed ?
-
Sep 25th, 2021, 04:43 AM
#4
Re: Outlook forward item
Further investigation indicated that using the + sign to concatenate the strings rather than the & was causing the problem.
i noted the use of + instead the correct &, but did not think it was the cause of your problem
for htmlbody you should use html code for break <B> instead of vbnewline, try like
Code:
Newitem.HTMLbody =newitem.HTMLbody & "<B>text to add"
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 25th, 2021, 12:55 PM
#5
Thread Starter
Hyperactive Member
Re: Outlook forward item
That’s helpful, tried <B> which put it all in bold, and then spotted the typo that it should be <br>. All the worked ok.
Is there any way to test if the message format is in plain text or html ?
-
Sep 25th, 2021, 11:00 PM
#6
Re: Outlook forward item
Is there any way to test if the message format is in plain text or html ?
Code:
?newitem.bodyformat
returns 1 for plain text and 2 for html
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|