PC Review


Reply
Thread Tools Rate Thread

Original Attachment not removed

 
 
sd
Guest
Posts: n/a
 
      14th Aug 2009
hello

I've VSTO Addin for Outlook 2007.
I'm adding a dummy attachment in BeforeAttachment event & removing
original attachment.
But the attachment list still shows me original attachment along with
dummy attachment.
Besides this when I drag drop or insert attachment the cursor position
changes.
I also need to insert a link at current cursor position.so the cursor
position should not change
for proper link insertion.
Below is the code I'm using -

strMyTmpFilePath = IO.Path.Combine(strMyTmpFilePath,
strMyTmpFileName)
IO.File.AppendAllText(strMyTmpFilePath, "this is a dummy
file")
CurrentMailItem.Attachments.Add(strMyTmpFilePath)
IO.File.Delete(strMyTmpFilePath)
Cancel = True
'Code to add Link at cursor position
Dim ObjSel As Object = CurrentInsp.WordEditor.Application.Selection
With ObjSel
Dim Rg As Object
.MoveRight(Unit:=2, Count:=1) 'wdWord=2
Rg = .range
.Hyperlinks.Add(Anchor:=Rg, Address:=strAttachmentURL _
, TextToDisplay:=strNewLink.ToString)
.InsertAfter(" ")
End With
If Rg IsNot Nothing Then Marshal.FinalReleaseComObject(Rg)
If ObjSel IsNot Nothing Then Marshal.FinalReleaseComObject(ObjSel)


Thanks
 
Reply With Quote
 
 
 
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      14th Aug 2009
Try saving the item after you add your new attachment and again after you
remove the old one.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"sd" <(E-Mail Removed)> wrote in message
news:615ab412-3a80-4272-9f4d-(E-Mail Removed)...
> hello
>
> I've VSTO Addin for Outlook 2007.
> I'm adding a dummy attachment in BeforeAttachment event & removing
> original attachment.
> But the attachment list still shows me original attachment along with
> dummy attachment.
> Besides this when I drag drop or insert attachment the cursor position
> changes.
> I also need to insert a link at current cursor position.so the cursor
> position should not change
> for proper link insertion.
> Below is the code I'm using -
>
> strMyTmpFilePath = IO.Path.Combine(strMyTmpFilePath,
> strMyTmpFileName)
> IO.File.AppendAllText(strMyTmpFilePath, "this is a dummy
> file")
> CurrentMailItem.Attachments.Add(strMyTmpFilePath)
> IO.File.Delete(strMyTmpFilePath)
> Cancel = True
> 'Code to add Link at cursor position
> Dim ObjSel As Object = CurrentInsp.WordEditor.Application.Selection
> With ObjSel
> Dim Rg As Object
> .MoveRight(Unit:=2, Count:=1) 'wdWord=2
> Rg = .range
> .Hyperlinks.Add(Anchor:=Rg, Address:=strAttachmentURL _
> , TextToDisplay:=strNewLink.ToString)
> .InsertAfter(" ")
> End With
> If Rg IsNot Nothing Then Marshal.FinalReleaseComObject(Rg)
> If ObjSel IsNot Nothing Then Marshal.FinalReleaseComObject(ObjSel)
>
>
> Thanks


 
Reply With Quote
 
 
 
 
sd
Guest
Posts: n/a
 
      19th Aug 2009
Thanks Ken
I saved item after new attachment addition & also after removing the
old one.But no success.Attachment list not refreshed.
Also I don't want to save item (if the user cancels send then I will
have to remove this item from drafts).I reassigned the body
format,that refreshes the attachment list.But in plain text mode link
is not recognized (it is displayed as plain text) & cursor position
again set to starting of message body .
Is there any way so the link gets recognized & also cursor position
doesn't change? If I don't add new attachment ,just remove the old
one & add the link then there is no problem link is recognized &
cursor position also not changed.
 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      19th Aug 2009
I don't know about forcing a refresh as well as not changing the cursor
position. However, that's not really an issue, since you can always get the
cursor position first before it changes. That should help.

See if faking out Outlook helps, something like item.Body = item.Body. But I
think you're going to have to save. I usually use a flag in those cases,
first I check the Saved property and then I flag my save if needed, then I
handle the Write() event on the item and if I didn't fire that event by
saving it's the user who did it (or auto-save). Then I can work out if I
need to delete the item from Drafts if necessary.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"sd" <(E-Mail Removed)> wrote in message
news:3d84b636-4781-4edb-82ff-(E-Mail Removed)...
> Thanks Ken
> I saved item after new attachment addition & also after removing the
> old one.But no success.Attachment list not refreshed.
> Also I don't want to save item (if the user cancels send then I will
> have to remove this item from drafts).I reassigned the body
> format,that refreshes the attachment list.But in plain text mode link
> is not recognized (it is displayed as plain text) & cursor position
> again set to starting of message body .
> Is there any way so the link gets recognized & also cursor position
> doesn't change? If I don't add new attachment ,just remove the old
> one & add the link then there is no problem link is recognized &
> cursor position also not changed.


 
Reply With Quote
 
sd
Guest
Posts: n/a
 
      20th Aug 2009
Thanks Ken
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter (to removed unread messages) removed, but keeps coming back Gail Microsoft Outlook Discussion 1 24th Jan 2010 04:29 AM
I can't install a not original program in original windows xp =?Utf-8?B?RmVycmF6?= Windows XP Help 0 22nd Feb 2007 01:01 AM
Row removed from a dataset table is not removed from a database tableduring update nvx Microsoft ADO .NET 2 3rd Aug 2006 08:15 PM
Row removed from a dataset is not removed from a table during update nvx Microsoft ADO .NET 0 3rd Aug 2006 05:42 PM
Original of forwarded mail is removed from Inbox Roberto Ramasso Microsoft Outlook Discussion 1 21st Jul 2004 12:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:57 PM.