A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Moving email attachment into inbox...



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 8th 08, 01:06 AM posted to microsoft.public.outlook.program_vba
Bennett[_2_]
external usenet poster
 
Posts: 2
Default Moving email attachment into inbox...

I have a minor issue which is annoying. I have set up my work email to
forward to my Gmail account which I can access via POP in Outlook 2007. My
emails are sent as attachments and I can't change this.

I have Vista Sideshow set up to view my Outlook emails but it won't display
any attachments.

I can manually move (literally click and drag) the email attachment from the
email to my inbox in Outlook and it appears as a separate email (woohoo!).
Great. But the whole point is not to have to do this manually. About half
my emails are from this account, and most of the important ones are, so this
would be nice to fix.

I've tried writing a VBA macro to do this, but it insists on treating the
email attachment as an attachment, which in fact it's really a MailItem. The
software is clearly capable of dragging .msg files into the Outlook Inbox.
But how on earth do I tell Outlook to do that using VBA..? I kind of want to
"save" the "attachment" but specifically save it into the Outlook Inbox, NOT
a directory on the HDD.

Any ideas?
Ads
  #2  
Old October 8th 08, 02:21 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Moving email attachment into inbox...

In general to work with any attachment you must save it to the file system
first. However, importing a MSG file from the file system or dealing with it
in any other way in code is not exposed in the Outlook object model. There's
a 3rd party library, Redemption (www.dimastr.com/redemption), that does let
you open and import MSG files into Outlook using code.

--
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


"Bennett" wrote in message
...
I have a minor issue which is annoying. I have set up my work email to
forward to my Gmail account which I can access via POP in Outlook 2007.
My
emails are sent as attachments and I can't change this.

I have Vista Sideshow set up to view my Outlook emails but it won't
display
any attachments.

I can manually move (literally click and drag) the email attachment from
the
email to my inbox in Outlook and it appears as a separate email (woohoo!).
Great. But the whole point is not to have to do this manually. About
half
my emails are from this account, and most of the important ones are, so
this
would be nice to fix.

I've tried writing a VBA macro to do this, but it insists on treating the
email attachment as an attachment, which in fact it's really a MailItem.
The
software is clearly capable of dragging .msg files into the Outlook Inbox.
But how on earth do I tell Outlook to do that using VBA..? I kind of want
to
"save" the "attachment" but specifically save it into the Outlook Inbox,
NOT
a directory on the HDD.

Any ideas?


  #3  
Old October 9th 08, 12:58 AM posted to microsoft.public.outlook.program_vba
Bennett[_2_]
external usenet poster
 
Posts: 2
Default Moving email attachment into inbox...

Thanks, I did find a way to do it.

Public Sub RemoveAttachments2(item As MailItem)

Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim Atmt As Attachment
Dim FileName As String
Dim itemnew As Object
Dim foundemail As Boolean
foundemail = False

Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)

For Each Atmt In item.Attachments

If Right(Atmt.FileName, 3) = "msg" Then ' checks for true email
attachments
foundemail = True
FileName = "c:\temp\"

Atmt.SaveAsFile FileName & Atmt.FileName

Set itemnew = Outlook.Application.CreateItemFromTemplate(FileNam e &
Atmt.FileName, Inbox)
itemnew.Save ' otherwise it saves a copy into OutBox...
itemnew.Move Inbox
itemnew.UnRead = True ' this doesn't work yet, not sure why
End If

Next Atmt

item.Move ns.GetDefaultFolder(olFolderDeletedItems) ' I can do this
because it only acts on postmaster emails!
End Sub

It's a little around the houses, but it works ) As you said, it required
me to save the file to the HDD first, which in itself wasn't as much as
problem as it not apparently being reopened as an email item. (Using
CreateItemFromTemplate did the trick).

Cheers

Bennett


"Ken Slovak - [MVP - Outlook]" wrote:

In general to work with any attachment you must save it to the file system
first. However, importing a MSG file from the file system or dealing with it
in any other way in code is not exposed in the Outlook object model. There's
a 3rd party library, Redemption (www.dimastr.com/redemption), that does let
you open and import MSG files into Outlook using code.

--
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


"Bennett" wrote in message
...
I have a minor issue which is annoying. I have set up my work email to
forward to my Gmail account which I can access via POP in Outlook 2007.
My
emails are sent as attachments and I can't change this.

I have Vista Sideshow set up to view my Outlook emails but it won't
display
any attachments.

I can manually move (literally click and drag) the email attachment from
the
email to my inbox in Outlook and it appears as a separate email (woohoo!).
Great. But the whole point is not to have to do this manually. About
half
my emails are from this account, and most of the important ones are, so
this
would be nice to fix.

I've tried writing a VBA macro to do this, but it insists on treating the
email attachment as an attachment, which in fact it's really a MailItem.
The
software is clearly capable of dragging .msg files into the Outlook Inbox.
But how on earth do I tell Outlook to do that using VBA..? I kind of want
to
"save" the "attachment" but specifically save it into the Outlook Inbox,
NOT
a directory on the HDD.

Any ideas?



  #4  
Old February 9th 09, 07:07 PM posted to microsoft.public.outlook.program_vba
Aaron
external usenet poster
 
Posts: 23
Default Moving email attachment into inbox...

Hi Ken,
I am having the same problem. I have downloaded and installed
Redemption, but I still can't seem to get this to work. Do you have idea
where my code is wrong? Thanks!

Public Sub CopyAttachment(myMailItem As Outlook.MailItem)

Dim NS As Outlook.NameSpace
Dim olkFolderset As Outlook.Folders
Dim olkFolder As Outlook.Folder
Dim olkAttachedMSG, olkMailItem, olkNewMailItem As Outlook.MailItem
Dim redAttachment, redMailItem As Object
Dim strID As String

strID = myMailItem.EntryID
Set NS = Outlook.GetNamespace("MAPI")
Set olkFolder = NS.OpenSharedFolder("ITCS (POP)\Inbox")
Set olkMailItem = NS.GetItemFromID(strID)
Set redMailItem = CreateObject("Redemption.SafeMailItem")
redMailItem.item = olkMailItem
Set redAttachment = redMailItem.Attachment
Set olkAttachedMSG = redAttachment.EmbeddedMsg
Set olkNewMailItem = Outlook.CreateItem(olMailItem)
olkAttachedMSG.CopyTo (olkNewMailItem)
olkNewMailItem.Save
olkNewMailItem.Move (olkFolder)

End Sub

"Ken Slovak - [MVP - Outlook]" wrote:

In general to work with any attachment you must save it to the file system
first. However, importing a MSG file from the file system or dealing with it
in any other way in code is not exposed in the Outlook object model. There's
a 3rd party library, Redemption (www.dimastr.com/redemption), that does let
you open and import MSG files into Outlook using code.

--
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


"Bennett" wrote in message
...
I have a minor issue which is annoying. I have set up my work email to
forward to my Gmail account which I can access via POP in Outlook 2007.
My
emails are sent as attachments and I can't change this.

I have Vista Sideshow set up to view my Outlook emails but it won't
display
any attachments.

I can manually move (literally click and drag) the email attachment from
the
email to my inbox in Outlook and it appears as a separate email (woohoo!).
Great. But the whole point is not to have to do this manually. About
half
my emails are from this account, and most of the important ones are, so
this
would be nice to fix.

I've tried writing a VBA macro to do this, but it insists on treating the
email attachment as an attachment, which in fact it's really a MailItem.
The
software is clearly capable of dragging .msg files into the Outlook Inbox.
But how on earth do I tell Outlook to do that using VBA..? I kind of want
to
"save" the "attachment" but specifically save it into the Outlook Inbox,
NOT
a directory on the HDD.

Any ideas?



  #5  
Old February 9th 09, 07:17 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Moving email attachment into inbox...

You still need to save the attachment to the file system no matter what. Use
SaveAs to save the file as a MSG file and then you can use
RDOSession.CreateMessageFromMsgFile to create an RDOMail item from the saved
MSG file, assuming it is actually an Outlook object saved as a MSG file.

--
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


"Aaron" wrote in message
...
Hi Ken,
I am having the same problem. I have downloaded and installed
Redemption, but I still can't seem to get this to work. Do you have idea
where my code is wrong? Thanks!

Public Sub CopyAttachment(myMailItem As Outlook.MailItem)

Dim NS As Outlook.NameSpace
Dim olkFolderset As Outlook.Folders
Dim olkFolder As Outlook.Folder
Dim olkAttachedMSG, olkMailItem, olkNewMailItem As Outlook.MailItem
Dim redAttachment, redMailItem As Object
Dim strID As String

strID = myMailItem.EntryID
Set NS = Outlook.GetNamespace("MAPI")
Set olkFolder = NS.OpenSharedFolder("ITCS (POP)\Inbox")
Set olkMailItem = NS.GetItemFromID(strID)
Set redMailItem = CreateObject("Redemption.SafeMailItem")
redMailItem.item = olkMailItem
Set redAttachment = redMailItem.Attachment
Set olkAttachedMSG = redAttachment.EmbeddedMsg
Set olkNewMailItem = Outlook.CreateItem(olMailItem)
olkAttachedMSG.CopyTo (olkNewMailItem)
olkNewMailItem.Save
olkNewMailItem.Move (olkFolder)

End Sub


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail missing after moving from inbox. Louis[_2_] Outlook Express 1 March 5th 08 03:18 PM
Moving PST Messages to exchange Inbox [email protected] Outlook - General Queries 6 April 18th 07 04:01 AM
Moving a .msg attachment to folder IncJourn Outlook and VBA 1 August 23rd 06 05:55 PM
How can I save an attachment that is an email to my inbox? matt69 Outlook and VBA 5 April 14th 06 06:19 AM
rules not moving messages from inbox Jessie~ Outlook - General Queries 1 January 13th 06 03:34 AM


All times are GMT +1. The time now is 11:37 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.