Results 1 to 6 of 6
  1. #1
    Join Date
    May 2011
    Posts
    19

    Red face outlook problem ... killing me !!!!

    hello peeps,

    got a bit of an issue here,

    i am trying to use VBA in outlook and save a copy of e-mails coming in one of the folders in public folders to the local/network drives in a folder.

    been looking for some code to get a clue but no use, anyone can help please ....

  2. #2
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Do you have access to the mail server?
    Are the emails all to the same email address?

  3. #3
    Join Date
    May 2011
    Posts
    19
    yes i have access to mail server, as the emails are in public folder and i have power user rights to these areas, also the macro will run in the background so the normal users will not be effected.

    i have tried a bit of code but its not working.

    Sub MoveSelectedMessagesToFolder()

    On Error Resume Next
    Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
    Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
    Set objNS = Application.GetNamespace("MAPI")
    Set objInbox = objNS.GetDefaultFolder(olFolderInbox)

    ' Select your destination folder
    ' Assume this is a mail folder
    Set objFolder = GetFolder(" network drive address ")

    If objFolder Is Nothing Then
    MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation, "Invalid Folder"
    End If

    If Application.ActiveExplorer.Selection.Count = 0 Then
    'Ensures that a message is selected
    MsgBox "Nothing selected", vbOKOnly + vbExclamation, "No message selected"
    Exit Sub
    End If

    For Each objItem In Application.ActiveExplorer.Selection
    If objFolder.DefaultItemType = olMailItem Then
    If objItem.Class = olMail Then
    objItem.Move objFolder
    End If
    End If
    Next

    Set objItem = Nothing
    Set objFolder = Nothing
    Set objInbox = Nothing
    Set objNS = Nothing

    End Sub

    Public Function GetFolder(StrFolderPath As String) As MAPIFolder
    ' folder path needs to be something like
    ' "\\Public Folders\All Public Folders\Coatsbridge\Link\2. Routine\"
    Dim objApp As Outlook.Application
    Dim objNS As Outlook.NameSpace
    Dim colFolders As Outlook.Folders
    Dim objFolder As Outlook.MAPIFolder
    Dim arrFolders() As String
    Dim i As Long
    On Error Resume Next

    StrFolderPath = Replace(StrFolderPath, "/", "\")
    arrFolders() = Split(StrFolderPath, "\")
    Set objApp = CreateObject("Outlook.Application")
    Set objNS = objApp.GetNamespace("MAPI")
    Set objFolder = objNS.Folders.Item(arrFolders(0))
    If Not objFolder Is Nothing Then
    For i = 1 To UBound(arrFolders)
    Set colFolders = objFolder.Folders
    Set objFolder = Nothing
    Set objFolder = colFolders.Item(arrFolders(i))
    If objFolder Is Nothing Then
    Exit For
    End If
    Next
    End If

    Set GetFolder = objFolder
    Set colFolders = Nothing
    Set objNS = Nothing
    Set objApp = Nothing
    End Function





    Quote Originally Posted by kitaman View Post
    Do you have access to the mail server?
    Are the emails all to the same email address?

  4. #4
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Since you have access to the server, I would add an alias that is a process (script) and then use it to direct all/some emails to the new destination, and not try to extract it from the outlook mail box.
    I can give you some ksh examples if the server is sendmail.

  5. #5
    Join Date
    May 2011
    Posts
    19
    Quote Originally Posted by kitaman View Post
    Since you have access to the server, I would add an alias that is a process (script) and then use it to direct all/some emails to the new destination, and not try to extract it from the outlook mail box.
    I can give you some ksh examples if the server is sendmail.
    ohh actually i don't have access to active directory, that's the reason i am using a macro and code.

    any suggestions ?

  6. #6
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Maybe someone else can help, I don't do any MS stuff.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •