Results 1 to 6 of 6

Thread: Attachment To MailItem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2004
    Posts
    297

    Attachment To MailItem

    Hi there,

    How do I put an attachment (which is a mailItem) into a MailItem Object?
    Like this:
    Dim oAttach As Outlook.Attachment
    Dim myOlMail As Outlook.MailItem
    For Each oAttach In myEmail.Attachments
    Set myOlMail = oAttach
    Next

    The problem here is that VB sees the attachment as an Attachment and not as a mailitem...
    Last edited by HWijngaarD; May 23rd, 2006 at 02:44 AM.

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Attachment To MailItem

    Dont you need to use :
    Code:
    myEmail.Attachments.Add(....?)
    (Guessing here).
    You may have to make an attachment object first then add that object to the attachments collection. Should be mentioned in the help files.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Attachment To MailItem

    You need to use .CreateItemFromTemplate to open the attached mailitem.

    Heres one of my c0d examples:


    http://www.vbforums.com/showthread.php?t=347353
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2004
    Posts
    297

    Re: Attachment To MailItem

    This is my situation:
    I've got a Task Item wich contains an email as attachment.
    This email I'd like to set in an EmailItem Object.
    But this won't work cause the Email is an attachmentItem.
    So I need somehow convert this attachment into a mailobject or something like that.

    But if this cannot be done then so be it...

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Attachment To MailItem

    It can be done. Just need to modify my code example to initially get the TaskItem instead of a mailItem. Then CreateItemFromTemplate to open the saved mailitem and moved into your Inbox.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2004
    Posts
    297

    Re: Attachment To MailItem

    Thanks Yoda!
    This is probably the only solution...

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