Results 1 to 38 of 38

Thread: ...Outlook Vb

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ...Outlook Vb

    I am currently sending an e-mail via VB to a client...
    I would like to save this sent message into a corresponding folder automatically...
    Any ideas?

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    use the 'SaveSentMessageFolder' property of the email mesage.
    Set the property of the email equal to the MAPI folder where you
    want to have the copy saved to.
    Code:
    Set oEmail.SaveSentMessageFolder = oApp.oNS.oSent
    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

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    remember

    Remember Rob

    I am sending via IE... How do I know that the user has not hit Cancel instead of sent

    ls_Browser = FindDefaultBrowser
    Shell ls_Browser & " mailto:" & strEMail1Address & "?subject=" & "[Sent via ACMS]"

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    Me again

    I just switch to the following

    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

    With objOutlookMsg
    .To = strEMail1Address
    .Subject = "[Sent via ACMS]"

    .Importance = olImportanceHigh

    .Display 1

    Set .SaveSentMessageFolder = gf_olfolder

    Now

    The gf_olfolder is a subfolder in ALL PUBLIC FOLDERS which is
    a subfolder under PUBLIC FOLDERS

    What should gf_folder be ? Just the name of the folder
    How does one specify full folder path

    Thanks

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    I think that using the Outlook object model is the best way to go
    if yuo need total control. If you need to save the sent item to
    a public folder then do this.
    Code:
    'In your procedure, drill down the path
    Dim oApp As New Outlook.Application
    Dim oNS As Outlook.NameSpace
    Dim oPF As Outlook.MAPIFolder
    Dim oAPF As Outlook.MAPIFolder
    Dim ogf_olfolder As Outlook.MAPIFolder
    
    Set oNS = oApp.GetNamespace("MAPI")
    Set oPF = oNS.Folders("Public Folders")
    Set oAPF = oPF.Folders("All Public Folders")
    Set ogf_olfolder = oAPF.Folders("ogf_olfolder")
    
    Set oEmail.SaveSentMessageFolder = ogf_olfolder
    
    Set oApp = Nothing
    Set oNS = Nothing
    Set oPF = Nothing
    Set oAPF = Nothing
    Set ogf_olfolder = Nothing
    'Then go on to send your email
    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
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492
    This is close...but what if Outlook is closed?

    Its better to check if outlook is opened on the user end...otherwise the user will get a security permission error.

    Check if outlook is open..if not open it on the client side send the email and then close it.

    Jon

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    That is not correct. The statement of code -
    Code:
    Dim oApp As New Outlook.Application
    will create an instance of Outlook, so if the user is already in
    Outlook, this will attach to it.
    Otherwise it will be a New separate process and the user will
    have to select the profile to log on with.
    My example was just a partial procedure for him to incorporate
    into his procedure.

    Late.
    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
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492
    Originally posted by RobDog888
    That is not correct. The statement of code - [code
    Late.
    Wanna put your bottom dollar on this one? If outlook is not running as a process (PID) on a client machine than an error message will pop up AS LONG AS the programmer has caught the exception, i.e:

    VB Code:
    1. on error goto err_handler
    2.  
    3. done:
    4. exit sub
    5.  
    6. err_handler:
    7. msgbox err.description,vbcritical, "error #: " & err.number
    8. resume done

    Just because you have created an outlook object...does not mean your email will be sent..in fact it IS NOT sent. Outlook or your standard e-mail client needs to be open at the time you instantiate an Outlook object.

    Jon

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    I would put money on it because I just double checked.
    I depends upon what you are trying to do in Outlook.
    If you are trying to create email and send it on a client machine
    in an Exchange enviroment, then it will create a new instance
    of Outlook, but not visible unless your code specifies it. It WILL
    send the email(s). If you are trying to connect to public forders,
    then you will need to login with your profile through code.

    I can admit that I didn't realize that he would need to do that
    because he wants to save a copy of the email in a public folder
    on his exchange server, but for sending emails, it does work.
    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
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Originally posted by RobDog888
    That is not correct. The statement of code -
    Code:
    Dim oApp As New Outlook.Application
    will create an instance of Outlook
    I don't want to be this picky really but I can't help myself because I'm bored

    Setting an object (any object) as New together with the declaration will actually not create an instance of that object. Instead it will be created on first use. In other words the first time you use a property or call a method of that object.

    This will actually slow down the process of working with that object because every time you use the object VB first have to check if it has created an instance or not. So the best way to create an object is to first declare it and then set it to new, in that case VB will create the object and no extra checks are necessary when using it.
    VB Code:
    1. Dim obj As Something
    2. Set obj = New Something
    Of course you would have to type an extra line of code

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Joacim,
    I read somewhere that declaring the variable with the New was a
    resource saver. I used to code it that way until I was informed
    on the way that I posted. It sound like your way is perhaps the
    correct way. One extra line of code won't kill me.
    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
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Originally posted by RobDog888
    Joacim,
    I read somewhere that declaring the variable with the New was a
    resource saver. I used to code it that way until I was informed
    on the way that I posted. It sound like your way is perhaps the
    correct way. One extra line of code won't kill me.
    Well, yeah... Setting an object as new on the declaration line could save some resources since the object will not be created unless it's used (this then comes with the performance hit I explained in my earlier post). But if you know you're going to use the object then it's always better to make sure an instance exists so your code will run a bit faster.

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

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

  14. #14
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492
    Originally posted by RobDog888
    I would put money on it because I just double checked.
    I depends upon what you are trying to do in Outlook.
    If you are trying to create email and send it on a client machine
    in an Exchange enviroment, then it will create a new instance
    of Outlook, but not visible unless your code specifies it. It WILL
    send the email(s). If you are trying to connect to public forders,
    then you will need to login with your profile through code.

    I can admit that I didn't realize that he would need to do that
    because he wants to save a copy of the email in a public folder
    on his exchange server, but for sending emails, it does work.
    Well isnt that something...it works on his machine so he implies it works on every machine on any WIN OS. Sorry...I've done integration with exchange and outlook too long..not going to argue this one. It is NOT correct unless outlook is open...if you catch the exception you will see that outlook NEEDS to be running to send anything...if a profile pops up...what do you think that means? On our exchange server I get an error message no pop up...the pop up is asking you for security purposes your network ID as well as a password or what have you not. This is HOW OUTLOOK is opening.

    Jon

  15. #15
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Originally posted by jhermiz
    Well isnt that something...it works on his machine so he implies it works on every machine on any WIN OS. Sorry...I've done integration with exchange and outlook too long..not going to argue this one. It is NOT correct unless outlook is open...if you catch the exception you will see that outlook NEEDS to be running to send anything...if a profile pops up...what do you think that means? On our exchange server I get an error message no pop up...the pop up is asking you for security purposes your network ID as well as a password or what have you not. This is HOW OUTLOOK is opening.

    Jon
    Ok, granted it doesn't work with the way that YOU have it
    set up, but that does not mean that it doesn't work for anyone else.
    Outlook can be configured may ways and it is difficult to develop
    for every possible scenerio.
    If it doesn't work for you unless Outlook is open, then perhaps
    it could just possibly work for others even if they don't have Outlook open.
    There is not a program that will not come accross an error on
    every platform. If it is working for Lafor then it helped and if
    it didn'nt then we can discuss other options to try. Is this not
    what this forum is for?

    BTW: I am running Outlook XP on Windows 2000 Pro on a
    Windows 2000 Active Directory network with Outgoing Mail Server not requiring authentication.
    Outlook configured as Corporate or Workgroup.
    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

  16. #16
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    I never had any problems creating a new Outlook.Application session either. Why wouldn't it work? However you might need to be validated by the Exchange server before you can send mail though. But you can definitly create a new Outlook session the way RobDog888 described.

  17. #17

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    What is oEmail defined as?

    Hello Guys!

    oEmail should be defined as what?

  18. #18
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Code:
    Dim oEmail As Outlook.MailItem
    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

  19. #19

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ok

    This would not work... after I send the email
    I get the message... Item has been moved or deleted

    Set ogf_olfolder = oAPF.Folders("AHA")
    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

    With objOutlookMsg
    .To = strEMail1Address
    .Subject = "TEST"
    .Display 1

    Set .SaveSentMessageFolder = ogf_olfolder

    End With
    Any idea??? Am I missing something?

  20. #20
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Check the public folder you want to save it to. I think it may have been renamed.
    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

  21. #21

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    not really

    I can go back to it and look at it..

    Did it work for you?

  22. #22
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    It will not let me save a copy in the public folder I set it to.
    It says 'Operation Failed!"
    I think it may have to do with the public folders not allowing
    Message types in public folders.
    It will not let me change the default form to anything other than
    post.
    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

  23. #23

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ...

    I got the same error message..

    My guess is that the item is sent.. and is no longer available
    to be copied or moved to another place...

    Notice that the message is actually send, it's the save operation
    that's failed...

    I also notice that if I do

    prior to the display

    a SaveSentMessageFolder.copyto gf_oldfolder

    It will move all the items in the sent box onto my destination folder.. I was actually trying to find a way to get the last item entered and do the move or the copy.. but, "item is not found either"

  24. #24
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Is your Sent Items still on your personal folder list?
    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

  25. #25

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    yes

    ...It is

  26. #26
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    I accidentally renamed my Sent Items folder to Development.
    I had created a public folder Development and was trying to
    have the SaveSentMessages to this folder, but it renamed my
    personal Sent tems folder to Development. I finally got it
    renamed back.

    I guess the copyto method is safer for the public folder.
    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

  27. #27
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    I go it working to send a copy to the public folder for the specific
    item only.
    My public folder is "Development". I used the .Copy and .Move
    methods of the actual email as its being sent.
    Code:
    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
        
        Dim oEmail As Outlook.MailItem
        Dim oNS As Outlook.NameSpace
        Dim oPF As Outlook.MAPIFolder
        Dim oAPF As Outlook.MAPIFolder
        Dim oDev As Outlook.MAPIFolder
        Dim oCopyEmail As Outlook.MailItem
        
        Set oNS = Application.GetNamespace("MAPI")
        Set oPF = oNS.Folders("Public Folders")
        Set oAPF = oPF.Folders("All Public Folders")
        Set oDev = oAPF.Folders("Development")
    
        Set oEmail = Item
        Set oCopyEmail = oEmail.Copy
        oCopyEmail.Move oDev
        
        Set oEmail = Nothing
        Set oCopyEmail = Nothing
        Set oNS = Nothing
        Set oPF = Nothing
        Set oAPF = Nothing
        Set oDev = Nothing
        
    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

  28. #28

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ...

    Thanks...

    I'll try that,.... But what I have decided to do in the mean time
    is to associate an e-mail to each of these folders and
    upon sending the e-mail I bcc to the [email protected]
    So the e-mail will be put in the mail box of the organization

    I just had to modify the code to point to the INBOX of the organization rather than the public folder... But, I'll try it


    Thanks a mil

  29. #29
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Your welcome.
    My method might be better for you. The receipient can not
    see any info from the cc field and there is no information
    embedded into the email message.
    I really get into Outlook, as you can probably tell!
    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

  30. #30

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ...Yeah!

    U're deep into it....

  31. #31
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    I like the challenge. So if you have anything concerning Outlook
    or Office, don't hesitate to let me know.
    I need new deeper areas to get into with Outlook.
    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

  32. #32

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    Outlook forms

    Me again..

    I would like to copy some fields on an outlook form as is
    and paste onto my VB form.. Is that doable?

  33. #33
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Sure. Just "Find" to the item and read the properties you
    need into your vb form.

    Connect to the folder and use the .Find method to return the item.
    Something like...
    Code:
    'INITIALIZE OUTLOOK CONNECTION
    Set oApp = New Outlook.Application
    Set oNS = oApp.GetNamespace("MAPI")
    Set oTaskBox = oNS.GetDefaultFolder(olFolderTasks)
    Set oItems = oTaskBox.Items
        
    oItems.Find = "[Subject] = 'Test'"
    
    txtSubject = oItems.Subject
    txtCreatedDate = oItems.CreatedDate
    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

  34. #34
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    The code needs to go behind your VB form not in Outlook VBA.
    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

  35. #35
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    Mt two cents :

    Make sure Outlook is installed or it won't matter anyway...

    VB Code:
    1. ' USED FOR THE EXISTANCE OF OUTLOOK '************************************************
    2.  
    3. Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    4. Private Declare Function RegEnumKey Lib "advapi32.dll" Alias "RegEnumKeyA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, ByVal cbName As Long) As Long
    5. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    6.  
    7. ' USAGE
    8.  
    9. ' SEE IF OUTLOOK INSTALLED ON SYSTEM
    10.    
    11. Call OUTLOOKINSTALLED
    12.  
    13. Function OUTLOOKINSTALLED() As Boolean
    14.  
    15.    OUTLOOKINSTALLED= False
    16.    
    17.     Dim sKey As String * 255
    18.     Dim lRegKey As Long
    19.     Dim iKey As Integer
    20.    
    21.     Call RegOpenKey(HKEY_LOCAL_MACHINE, "Software\Clients\Mail", lRegKey)
    22.      
    23.     While RegEnumKey(lRegKey, iKey, sKey, 255) = 0
    24.        
    25.         If Left(sKey, InStr(sKey, Chr(0)) - 1) = "Microsoft Outlook" Then
    26.        
    27.         OUTLOOKINSTALLED = True
    28.  
    29.         End If
    30.  
    31.         iKey = iKey + 1
    32.        
    33.     Wend
    34.    
    35.     Call RegCloseKey(lRegKey)
    36.    
    37. End Sub
    Last edited by James Stanich; Jun 4th, 2003 at 03:42 PM.
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  36. #36

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ....

    Was thinking of opening the task form in design mode and
    cut/paste some fields into VB form...

    But, Rob's idea could become veryhandy at some point...

    Thanks

  37. #37
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    You can't copy and paste outlook controls to vb.
    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

  38. #38

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    true

    Thanks

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