Results 1 to 6 of 6

Thread: Outlook forward item

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2010
    Posts
    402

    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.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2010
    Posts
    402

    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 ?

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2010
    Posts
    402

    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 ?

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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
  •  



Click Here to Expand Forum to Full Width