Please advise code received new mail

Status
Not open for further replies.

nguyennpa

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
Dear.
Please help me add this code in code below: If LCase(StrFolderName) = "inbox" Then
StrFile = StrSaveFolder & "e-from_" & StrSenderName & "_" & StrReceived & "_re_" & StrName & ".msg"
ElseIf LCase(StrFolderName) = "sent items" Then
StrFile = StrSaveFolder & "e-to_" & StrTo & "_" & StrReceived & "_re_" & StrName & ".msg"

- I want file backup the same : e-from_Timy A_20211103_0514pm_re_FW Test Mail

Private WithEvents InboxItems As Outlook.Items
Sub Application_Startup()

Dim xNameSpace As Outlook.NameSpace

Set xNameSpace = Outlook.Application.Session

Set InboxItems = xNameSpace.GetDefaultFolder(olFolderInbox).Items

End Sub


Private Sub InboxItems_ItemAdd(ByVal objItem As Object)

Dim FSO

Dim xMailItem As Outlook.MailItem

Dim xFilePath As String

Dim xRegEx

Dim xFileName As String

On Error Resume Next

xFilePath = CreateObject("WScript.Shell").SpecialFolders(16)

xFilePath = xFilePath & "\MyEmails"

Set FSO = CreateObject("Scripting.FileSystemObject")

If FSO.FolderExists(xFilePath) = False Then

FSO.CreateFolder (xFilePath)

End If

Set xRegEx = CreateObject("vbscript.regexp")

xRegEx.Global = True

xRegEx.IgnoreCase = False

xRegEx.Pattern = "\||\/|\<|\>|""|:|\*|\\|\?"

If objItem.Class = olMail Then

Set xMailItem = objItem

xFileName = xRegEx.Replace(xMailItem.Subject, "")

xMailItem.SaveAs xFilePath & "" & xFileName & ".msg", olMSG

End If

Exit Sub

End Sub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
C Outlook 365 Microsoft Support - Please Advise Using Outlook 3
Nufc1980 Outlook "Please treat this as private label" auto added to some emails - Help. Using Outlook 3
S Outlook 2002- "Send" button has disappeared. Help please. Using Outlook 1
S.Champ Please help? I've imported a random workcalendar I dont even know who's. Can I undo it? and then I need to re-sync the google one again. Its a mess:( Using Outlook 2
R Disable conversation thread from replying of recipients in the same subject. Please help Using Outlook 0
Marc2019 Need help please! Cannot Setup my outlook email account on my Mac Outlook 2011 Using Outlook.com accounts in Outlook 2
L Attachment saving and tracking - PLEASE help! Outlook VBA and Custom Forms 5
T Missing text in e-mail message after "(Please keep confidential)" Using Outlook 3
R "Can't store Outlook data files under the AppData folder. Please choose another folder." Using Outlook 6
J Help Please!!! Outlook 2016 - VBA Macro for replying with attachment in meeting invite Outlook VBA and Custom Forms 9
S VBA Macro - Run-time error '424': object required - Help Please Outlook VBA and Custom Forms 3
D Command Button code will not execute. Any suggestions Please. Outlook VBA and Custom Forms 2
L Outlook 2002: HTML Emails Will Not Print: Please Help Using Outlook 0
Diane Poremsky Testing please ignore Using Outlook 1
G Outlook 2010 VBA Coding Assistance please! Outlook VBA and Custom Forms 5
joflo copy contents from outlook to excell - please help. Using Outlook 4
A Help with VBA please! Outlook VBA and Custom Forms 15
Denis Hi everyone!!! Need some help with Excel to Exchange Calendar??PLEASE>>> Using Outlook 1
V Please help if you can. Problems with Bcc BCM (Business Contact Manager) 3
C Please Help outlook 2013 Using Outlook 1
J Please help to clarify an IMAP issue Using Outlook 7
M Address book doesn't update contacts? Please any help would be great! Exchange Server Administration 4
M Oh please read---> Extracting email web leads on to excel spread sheet Using Outlook 3
N Please help....winmail.dat issue...slowly going insane..... Using Outlook 1
E Need a bit of education on how Outlook works please Using Outlook 3
B Can someone please explain account set up from script Using Outlook 1
A help please -Boolean - can I use .AND NOT etc in a rule Exchange Server Administration 0
A Advanced find query facilty Help please Using Outlook 2
F Which upgrade should I go for and how do I do it please? Using Outlook 2
C Can't import distribution list - help, please Using Outlook 1
F Help with Outlook 2007 Macro Please! Using Outlook 4
V [duplicates duplicates duplicates] please help Using Outlook 26
I can't view email body please help! Using Outlook 6
R VBA Macro to VBScript in a form- Help Please! Using Outlook 10
M please customize this code Using Outlook 1
M please customize this code Using Outlook 1
S Need solution to Outlook mail handling/syncing/mobile situation, please Using Outlook 2
S Please help! -- Linked Account field at Business Contacts tab is always empty BCM (Business Contact Manager) 1
e_a_g_l_e_p_i Can someone please answer a question about tasks for me Using Outlook 2
A outlook error Receiving reported error (0x80040900) please help Using Outlook 4
D Help please my Outlook is frozen Using Outlook 3
H Outlook 2010: Cannot start!, please help me! Using Outlook 3
D Outlook 2007 not working>> Please help tried everything Using Outlook 3
U Need a help please Outlook 2007 crashing Using Outlook 2
M Updates to exchange server broke code - please help Using Outlook 2
K shared inbox help please Using Outlook 0
P Please Help me Create a Macro ! Using Outlook 2
J Help please Using Outlook 30
D A little bit of help with headers please? Exchange Server Administration 1
L PLEASE HELP: reconnect existing PST file to imap account Using Outlook 5

Similar threads

Back
Top