Results 1 to 12 of 12

Thread: forwarding a mail from a particular folder

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    forwarding a mail from a particular folder

    Hi ,

    I am developing an application,that needs me to list down all the mails in a
    particular folder under INBOX folder say folder -xxx,the user must be able to
    forward that particular item to any user.I am able to get all the mails from the INBOX using MAPI but i am not able to fetch it from the specified folder under INBOX. Please advice any example codes would be of great help.

    Thanks ,

    Khader

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: forwarding a mail from a particular folder

    Are you doing this in VB or Outlook VBA?

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

    Re: forwarding a mail from a particular folder

    How are you getting all the desired emails using mapi if you can not get the items? Are you using Outlook Object Model or VB's MAPI control?
    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
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Re: forwarding a mail from a particular folder

    Hi Guys ,

    Thanks for the response.See Currently i am using the MAPI to fetch all the mails from the inbox ,I am able to perform all the required funtions on them.
    but the trouble is i want to fetch and do similar actions on the mail items from other folders too which are under the inbox.I tried using the outlook objects here to navigate thru the folders ,I am able to open the mail but i want to forward them .Hope this is makes the case clear.

    Thanks ,

    Khader

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Re: forwarding a mail from a particular folder

    I am doing this on VB 6

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: forwarding a mail from a particular folder

    Show us the code you are using now.

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

    Re: forwarding a mail from a particular folder

    So this is specifically for your Outlook and not for other systems?

    If you create a search folder you could select all the found mail items and just forward them. Also, are you forwarding the emails to just one email arress or all different ones? Do you want to use the MAPI control or the Outook Object model?
    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

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Re: forwarding a mail from a particular folder

    Hi Robbdog and HACK,

    This is something that i used to move to a folder named "CAIT" ,I am also not sure how to declare myitems here.
    VB Code:
    1. Dim dosNameSpace As Outlook.NameSpace
    2. Dim dosPublics As MAPIFolder
    3. Dim myfolder As MAPIFolder
    4.  
    5. Set dosNameSpace = Application.GetNamespace("MAPI")
    6. Set dosPublics = dosNameSpace.GetDefaultFolder(olFolderInbox) 'should be the public
    7. Set myfolder = dosPublics.Folders("CAIT")
    8.  
    9. Set myitems = myfolder.Items
    10. myitems(2).display
    The following is my MAPI code that i use to fetch the mails and forward them

    This is to fetch the mails from inbox to a flexgrid....
    VB Code:
    1. Private Sub Command2_Click()
    2. 'MAPISession1.SignOn
    3. 'MAPIMessages1.SessionID = MAPISession1.SessionID
    4. MAPIMessages1.Fetch
    5. For i = 0 To MAPIMessages1.MsgCount - 1
    6. j = i + 1
    7. flxinb.Rows = flxinb.Rows + 1
    8. MAPIMessages1.MsgIndex = i
    9. flxinb.Row = j
    10. flxinb.Col = 0
    11. flxinb.Text = MAPIMessages1.MsgOrigDisplayName
    12. flxinb.Row = j
    13. flxinb.Col = 1
    14. flxinb.Text = MAPIMessages1.MsgSubject
    15. flxinb.Row = j
    16. flxinb.Col = 2
    17. flxinb.Text = MAPIMessages1.MsgDateReceived
    18. Next i
    19. 'MAPISession1.SignOff
    20. End Sub
    this is to forward ..
    VB Code:
    1. Private Sub cmdsnd_Click()
    2. If rdfrw.Value = True Then
    3. With MAPIMessages1
    4. .Fetch
    5. .MsgIndex = flxinb.Row - 1
    6. .Forward
    7. .MsgSubject = "Ticket ID"
    8. .RecipDisplayName = "[email protected]"  'email address
    9. .Show
    10. .MsgNoteText = "Hi Bo /Note this following forwareded message"
    11.  
    12. MAPIMessages1.Send True
    13. End With
    14. Else
    15. MsgBox "Please Select request type ", vbOKOnly, "ARM Ver 1.3"
    16. End If
    17.  
    18. End Sub
    While forwarding I also wanna use display the original message along with the new text .

    Can you guys advice me on both my problem

    1) To forward a mail from a particular folder under inbox by searching the subject line to any user.

    2) To append the forwarded mail instead of over writing it.

    Thanks and Regards,

    Khader






    Edit: Added [vbcode][/vbcode] tags for clarity and removed email address from post to protect member from possible spammers - Hack
    Last edited by Hack; Oct 10th, 2005 at 01:00 PM.

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

    Re: forwarding a mail from a particular folder

    Looks like your using both the vb6 mapi control and the outlook object model. There is no need to use both. If you have Outlook and this is just for you then its easier to just use Outlook.
    VB Code:
    1. Option Explicit
    2. 'Add a reference to MS Outlook xx.0 Object Library
    3. Private moApp As Outlook.Application
    4.  
    5. Private Sub Command1_Click()
    6.     Dim oInbox As Outlook.MAPIFolder
    7.     Dim i As Integer
    8.    
    9.     Set oInbox = moApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
    10.     For i = 1 To oInbox.Items.Count
    11.         flxinb.Row = i
    12.         flxinb.Col = 0
    13.         flxinb.Text = oInbox.Items.Item(i).Subject
    14.         flxinb.Row = i
    15.         flxinb.Col = 1
    16.         flxinb.Text = oInbox.Items.Item(i).SenderName
    17.         flxinb.Row = i
    18.         flxinb.Col = 2
    19.         flxinb.Text = oInbox.Items.Item(i).ReceivedTime
    20.     Next
    21.     Set oInbox = Nothing
    22. End Sub
    23.  
    24. Private Sub Form_Load()
    25.     Set moApp = New Outlook.Application
    26. End Sub
    27.  
    28. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    29.     moApp.Quit
    30.     Set moApp = Nothing
    31. End Sub
    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

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Re: forwarding a mail from a particular folder

    Hi RobDog,

    I accept to the fact that we can use any one of either MAPI or outlook,
    But my problem is that i need to forward mail and perform all functions on a particular mail that is present in a particular folder using a subject line search that is under INBOX .

    hope i am clear

    Khader

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

    Re: forwarding a mail from a particular folder

    Just do a loop checking the subject property. Then when found set a Mailitem object variable to that item and .Forward
    VB Code:
    1. If oInbox.Items.Item(i).Subject = "RE: Something" Then
    2.     Set oMsg = oInbox.Items.Item(i)
    3.     oMsg.Forward
    4.     oMsg.Receipients.Add "[email protected]"
    5.     oMsg.Send
    6. End If
    Check Outlooks help file for more info on the Fordward method. My code example is only detailed pseudocode.


    Moved from Classic VB forum.
    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

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Re: forwarding a mail from a particular folder

    Hi RobDog,

    Perfect Thanks a lot buddy will try that out ..Thanks a lot for all your help.

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