Saving Send emails to a folder on the server

I don't know what add-in that one is - but as long as the VB add-in is loaded, the macro will work.

I'm guessing klavplg is part of the parent apps name - maybe stands for klav plugin? Beyond that, I don't know what it is or what klav could be.
Hi Diane
I find out that it is Kaspersky add in.
Can you please help me with post# 38
 
Ok I run Outlook 2019 in safe mode (Outlook.exe /safe)
I then run Debug to cursor and get the following File Picker Dialog called Capture instead of the Correct Dialog (please see attachments). This happens in safe mode. In normal mode no popup dialog

View attachment 4267

View attachment 4268
There is something not correct in the file path - that is why it drops back to the user's folder.

You opened the path in file explorer and copied it from the address bar, correct?
 
Hi Diane
I find out that it is Kaspersky add in.
Can you please help me with post# 38
I wondered if it was that - but the L in the name mage me question it. :)
 
All I did was to copy the working code from Outlook 2021 and paste it into Outlook 2019 VBE and signed the code. The path for saving the email is the same as in Outlook 2021
 
There is something not correct in the file path - that is why it drops back to the user's folder.

You opened the path in file explorer and copied it from the address bar, correct?
No, I got the path from an on click event bihind a button of my email (outlook) automation saving a report in pdf format under client directory.

All I did was to copy the working code from Outlook 2021 and paste it into Outlook 2019 VBE and signed the code. The path for saving the email is the same as in Outlook 2021.

When Outlook 2019 is in safe and do a Debug to cursor then only does user folder popup. In normal mode nothing no dialog popup
 
If you copy the path and paste it into file explorer, does the folder open?

If you use your local documents folder, does it work?
Hi Diane
I tried the above nothing open. I post the code again maybe I am missing something
Code:
Private WithEvents objSentItems As Items

Private Sub Application_Startup()
Dim objSent As Outlook.MAPIFolder
Set objNS = Application.GetNamespace("MAPI")
Set objSentItems = objNS.GetDefaultFolder(olFolderSentMail).Items
Set objNS = Nothing
End Sub
 
Private Sub objSentItems_ItemAdd(ByVal oMail As Object)

 Dim sPath As String
  Dim dtDate As Date
  Dim sName As String
  Dim StrFolderpath As String
  Dim StrUserPath As Variant
 
  MsgBox "macro is running"

'Defaults to Documents folder
'get the function at http://slipstick.me/u1a2d
If oMail.MessageClass = "IPM.Note" Then

'StrUserPath = "\\JK_Server-PC\Users\JK_Server\Documents\JKBrokers\Clients\"
StrUserPath = "C:\Users\Server\Documents\"
StrFolderpath = BrowseForFolder(StrUserPath)

If StrFolderpath = "False" Then
      Cancel = True
      Exit Sub
  End If
 
  sName = oMail.Subject
  ReplaceCharsForFileName sName, "-"
 
  dtDate = oMail.ReceivedTime
  sName = Format(dtDate, "ddmmyyyy", vbUseSystemDayOfWeek, _
    vbUseSystem) & Format(dtDate, "-hhnnss", _
    vbUseSystemDayOfWeek, vbUseSystem) & "-" & sName & ".msg"
    
  sPath = StrFolderpath & "\"
  Debug.Print sPath & sName
  oMail.SaveAs sPath & sName, olMSG
 
  End If
 
End Sub

Private Sub ReplaceCharsForFileName(sName As String, _
  sChr As String _
)
  sName = Replace(sName, "'", sChr)
  sName = Replace(sName, "*", sChr)
  sName = Replace(sName, "/", sChr)
  sName = Replace(sName, "\", sChr)
  sName = Replace(sName, ":", sChr)
  sName = Replace(sName, "?", sChr)
  sName = Replace(sName, Chr(34), sChr)
  sName = Replace(sName, "<", sChr)
  sName = Replace(sName, ">", sChr)
  sName = Replace(sName, "|", sChr)
End Sub

Function BrowseForFolder(Optional OpenAt As Variant) As Variant
  Dim ShellApp As Object
  Set ShellApp = CreateObject("Shell.Application"). _
 BrowseForFolder(0, "Please choose a folder", 0, OpenAt)
 
 On Error Resume Next
    BrowseForFolder = ShellApp.self.Path
 On Error GoTo 0
 
 Set ShellApp = Nothing
    Select Case Mid(BrowseForFolder, 2, 1)
        Case Is = ":"
            If Left(BrowseForFolder, 1) = ":" Then GoTo Invalid
        Case Is = "\"
            If Not Left(BrowseForFolder, 1) = "\" Then GoTo Invalid
        Case Else
            GoTo Invalid
    End Select
 Exit Function
 
Invalid:
    BrowseForFolder = False
End Function
 
Is this the path on the computer Outlook is installed on?
C:\Users\Server\Documents\

In this screenshot it is OfficeWS?
1725547774428.png



Actually... it would be better to use the downloads folder - that way you know if macro is using the path in the script, not the default.
1725547706747.png



If you paste this into the address bar in file explorer, does it open?
\\JK_Server-PC\Users\JK_Server\Documents\JKBrokers\Clients\
 
Is this the path on the computer Outlook is installed on?
C:\Users\Server\Documents\

In this screenshot it is OfficeWS?
View attachment 4276


Actually... it would be better to use the downloads folder - that way you know if macro is using the path in the script, not the default.
View attachment 4275


If you paste this into the address bar in file explorer, does it open?
\\JK_Server-PC\Users\JK_Server\Documents\JKBrokers\Clients\
It should be OfficeWS I typed the wrong name. As this computer has 2 Users but main user OfficeWS.

I will do what you suggested during this weekend. I am off to play ⛳️ tomorrow.
 
Is this the path on the computer Outlook is installed on?
C:\Users\Server\Documents\

In this screenshot it is OfficeWS?
View attachment 4276


Actually... it would be better to use the downloads folder - that way you know if macro is using the path in the script, not the default.
View attachment 4275


If you paste this into the address bar in file explorer, does it open?
\\JK_Server-PC\Users\JK_Server\Documents\JKBrokers\Clients\
Diane, Yes the location opens if I copied the \\JK_Server-PC\Users\JK_Server\Documents\JKBrokers\Clients\ directly into File Explorer under user OfficeWS.

I Debug line for line in the VBE, Step Into jumps to Function BrowseForFolder skipping all the Private Subs above. Then OfficeWS Folder do popup.
Capture.JPG


If I copied C:\Users\OfficeWS\Downloads. I get this mesaage can't find path.
Can not find.JPG

I then remove the digital certificate re-added it, save the VBE file/save and also click the save icon, doing a double save,. Exit VBE and Outlook, svae the project and run Outlook. Send test email, nothing no folder to select popup.
 
I would definitely leave the macro unsigned until it is working.

Using any local path (copied from the address bar in file explorer - but not the documents folder (subfolder of documents ok) - does it work?
 
Step Into jumps to Function BrowseForFolder skipping all the Private Subs above.

When it hits StrFolderpath = BrowseForFolder(StrUserPath), it will jump to the browseforfolder sub - then when you select a folder, goes back to the main sub.
 
I would definitely leave the macro unsigned until it is working.

Using any local path (copied from the address bar in file explorer - but not the documents folder (subfolder of documents ok) - does it work?
Diane I try this tomorrow
 
When it hits StrFolderpath = BrowseForFolder(StrUserPath), it will jump to the browseforfolder sub - then when you select a folder, goes back to the main sub.
Diane
This what get when I select FAIS Files

File Folder.JPG
 
Diane, no this what the BrowseForFolder function debugged.
I am struggling to copy a path from the local drive. It gives server as user instead of OfficeWS user.

C:\users\server\pictures\
Instead of C:\users\OfficeWS\pictures

This C:\users\server\pictures all so do not popup anything.

The following users is one PC
Server (I have to ask my IT why this user is on this PC as only OfficeWS used this PC
OfficeWS (this one is what admin use)
 
Last edited:
Type C:\users\%username% in the address bar - what is the path? It's possible OfficeWS is the display name, not the alias name.

This is the result when I do it - the alias is diane but it uses my display name in the address bar - (signing in with Microsoft account)
1725908085161.png


The display name shows in the browse for folder dialog.

1725908229579.png
 
Type C:\users\%username% in the address bar - what is the path? It's possible OfficeWS is the display name, not the alias name.

This is the result when I do it - the alias is diane but it uses my display name in the address bar - (signing in with Microsoft account)
View attachment 4283

The display name shows in the browse for folder dialog.

View attachment 4284
 
Diane
C:\users\OfficeWS\Pictures show the below popup
1725979295736.png
 
Diane Yes
C:\users\%username% is OfficeWS

Is there away to hard code this.

StrUserPath = "\\JK_Server-PC\Users\JK_Server\My Documents\JKBrokers\Clients\"

See that I am struggling to get it wright on this machine.
 
Similar threads
Thread starter Title Forum Replies Date
N Saving .msg as sent item on send Outlook VBA and Custom Forms 1
Rupert Dragwater Background colors not saving in Outlook 365 Using Outlook 15
R Saving Emails and Attachments as .msg file Using Outlook 3
CWM330 Saving Data: Don't check certain folders Using Outlook 2
M Saving emails using Visual Basic - Selecting folder with msoFileDialogFolderPicker Outlook VBA and Custom Forms 6
D Outlook 2016 Outlook not saving Sent Items Using Outlook 4
I Error saving screenshots in a custom form in outlook 2016, outlook 365 - ok in outlook 2013, outlook 2010 Outlook VBA and Custom Forms 5
I Saving attachments from multiple emails and updating file name Outlook VBA and Custom Forms 0
M Adding Subject to this Link-Saving VBA Outlook VBA and Custom Forms 5
L Attachment saving and tracking - PLEASE help! Outlook VBA and Custom Forms 5
D Saving Selected Emails as PDF and saving Attachments Outlook VBA and Custom Forms 6
B Saving items under a folder Using Outlook 3
R Quick Access view in File Explorer when saving attachments Using Outlook 0
N Saving And Deleting Outlook Attachments with Unknown Error Message Outlook VBA and Custom Forms 1
V Saving attachment from outlook in My Documents Outlook VBA and Custom Forms 14
M Dialog called up multiple times when saving emails from macro Outlook VBA and Custom Forms 2
A saving attachement to folder named the same as rule name Outlook VBA and Custom Forms 0
T Saving all email to file folder in Windows Using Outlook 2
J Saving attachments from specific sender (phone number) to specific folder on hard drive Using Outlook 3
C Saving Outlook attachments and links to attachments with VBA Outlook VBA and Custom Forms 2
Kevin H Remotely saving emails Using Outlook 1
R Outlook 2010 Modify Style "Do not check spelling or grammar" not saving Outlook VBA and Custom Forms 0
R Outlook Office 365 not saving addresses Using Outlook 0
A Keep color categories when saving vCards Using Outlook 1
P Saving All Messages to the Hard Drive Using VBA Outlook VBA and Custom Forms 5
e_a_g_l_e_p_i question about saving my .pst so I can import it to my Outlook after I build a new system Using Outlook 10
S Editing an email with notes and saving it for record using Macro Outlook VBA and Custom Forms 3
O Saving Attachments to folder on disk and adding Initials to end of file name Outlook VBA and Custom Forms 9
J Outlook 2013 crashes saving VBA & clicking tools | digital signature Outlook VBA and Custom Forms 1
bifjamod Saving sent email to specific folder based on category with wildcard Outlook VBA and Custom Forms 1
erichamion Changes to meeting body not properly saving Outlook VBA and Custom Forms 4
A ItemAdd on Imap Folder get endless loop after saving item Using Outlook 5
T Saving Outlook 2010 email with attachments but read the email without Outlook Using Outlook 2
T From Field Blank when saving to folder other than Sent items Using Outlook 2
L Outlook DST (Daylight Saving Time) problem Using Outlook 0
F Using Outlook 2007 as an IMAP Mail Station Without Saving Data Locally Using Outlook 2
E Saving Changes To Edited E-Mail Received Message Using Outlook 0
D File Lock issue when saving message from Outlook to new folder Using Outlook 1
D Remove extension while saving attachments Using Outlook 1
K Printing & Saving Outlook Contacts Using Outlook 3
S Not saving attachments in the Sent Folder Using Outlook 2
S trouble with Outlook 2010 saving sent emails Using Outlook 2
D Saving outlook emails in html and attachments Using Outlook 4
W Default Saving a message as text Using Outlook 2
R Outlook 2007 QAT buttons not saving Using Outlook 2
C Exchange 2003 - Outlook 2003 - Calendar entries saving over each other Using Outlook 2
J Saving Published Outlook Form as msg Using Outlook 1
J Saving recent colors used for fonts in an email? Using Outlook 1
B How to choose which contacts folder to use when saving contacts? Using Outlook 1
J Saving Incoming & Outgoing Outlook 2010 Email Locally with IMAP Using Outlook 2

Similar threads

Back
Top