Avoid sending duplicate using Outlook script

Status
Not open for further replies.

Frederick Hung

New Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server 2013
Hi Diane, I have written an Outlook script to process incoming emails that meets the Outlook rules. The script will reformat the subject (based on the attachment), modify the body and then fwd the email to specified recipients.
It's been working well until recently we face a challenge, the same email may come from 2 different senders, and my script will process them individually which means it will Output to recipient twice. Is there any way to stop the script from processing duplicate?

One thing I can think of is to check the attachment name which is saved. Below is my current script, how can I enhance it to check for duplicate? Appreciated your help in advance.

Sub SendNew_Attach(Item As Outlook.MailItem)
Dim objMsg As MailItem
Set objMsg = Application.CreateItem(olMailItem)


If Item.Attachments.Count > 0 Then

Dim attCount As Long
Dim strFile As String
Dim sFileType As String
Dim strFolderpath As String
Dim objAttachments As Outlook.Attachments
Set objAttachments = objMsg.Attachments

attCount = Item.Attachments.Count
For i = attCount To 1 Step -1
strFile = Item.Attachments.Item(i).FileName

sFileType = LCase$(Right$(strFile, 4))

Select Case sFileType
Case "xlsx"
' do something if the file types are found
' this code fwd the attachment and change the email subejct n body
strFolderpath = CreateObject("WScript.Shell").SpecialFolders(16)
strFolderpath = strFolderpath & "\OLAttachments\"
strFile = strFolderpath & strFile

' Save the attachment as a file.
Item.Attachments.Item(i).SaveAsFile strFile

End Select
Next i
End If
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Should be able to use DIR instead - that would avoid using the filesystemobject (not that it's a big deal, but i like small and compact. :)

If Dir(strFile) <> "" Then
exit sub
end if
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
C How to avoid sending mail to the wrong contact person New Slipstick.com Articles 1
R How to configure outlook to avoid sending emails from the wrong account Using Outlook 24
R How to avoid reminders from delegators' Calendars? Using Outlook 1
H How to avoid the 'Exchange'-transcription of known mailadresses in the TO-field of mails Using Outlook 3
B how to add my own imap email account with full calendar privileges to exchange/outlook to avoid invites being sent 'on behalf of' my exchang Using Outlook 2
E How to avoid over lapping in Outlook 2003 calendar bookings Using Outlook 2
T Way to avoid annoying typecasts? VSTO V3 Using Outlook 3
C How to avoid an Outlook message that pops up Outlook VBA and Custom Forms 1
R Hi, Ken, What should be noticed to avoid memory leak in outlook addin? Outlook VBA and Custom Forms 3
D Sending email from Office 365 alias in Outlook Using Outlook 4
E Change sending account depending on Subjectline Outlook VBA and Custom Forms 0
L unblocking attachments before sending Office 365 Advanced Protection Using Outlook 0
B Outlook 2003 email sending & receiving suddenly stopped working Using Outlook 3
R Warn before sending message Outlook VBA and Custom Forms 4
HarvMan Hotmail - Sending email is undeliverable Using Outlook 4
A Sending contact vcards sends older version instead of updated version Using Outlook 4
M McAllister Outlook stops Sending/Receiving/Synching after disconnecting remote desktop session Using Outlook 2
D Adding Enterprise Exchange Email Account to Outlook Prevents Sending via Outlook.com Account Using Outlook.com accounts in Outlook 10
B When sending an email, I am showing 2 of my address's Using Outlook 1
M Auto expand Distribution List Before Sending Email Outlook VBA and Custom Forms 1
A Check for words in subject header before sending email Outlook VBA and Custom Forms 4
O Run macro automatically at sending an email Using Outlook 11
W Sending To Wrong Account Using Outlook 15
H Select Specific Account When Sending Email, Based on Current Folder Outlook VBA and Custom Forms 1
M Help sending email but removing signature via VBA Outlook VBA and Custom Forms 5
M MsgBox when not sending from specified account Outlook VBA and Custom Forms 2
A Script to fetch data from mails in restricted collection and sending them to excel Using Outlook 1
R Sending emails via Outlook XP, from Windows 10 File Explorer Using Outlook 1
L Creating drafts when I thought I was sending Using Outlook 1
C address book "when sending email" bug? Using Outlook 0
H Custom autoforwarding, sending mail through outlook office 365 Using Outlook 1
R Sending email copy (*.msg file) of sent email if subject line contains specific string. Outlook VBA and Custom Forms 1
C replace subject line generated by converting a word document to PDF and sending it to an email Using Outlook 8
A Sending Emails Through Outlook From Multiple Email Addresses Using Outlook 1
P Outlook 365 sending intermittently Using Outlook 0
V iCloud Calendar invitations not sending Using Outlook 3
O Rules and Alerts for New Messages BEFORE sending Using Outlook 2
latitudeit Outlook for Android - Sending from an alias address Using Outlook 2
X Delay sending an email until the next working day (public holidays) Outlook VBA and Custom Forms 0
D Macro sending outlook template from Excel list Outlook VBA and Custom Forms 6
A How to get rid of "sending on behalf of" when sending from Outlook 2016 client Using Outlook 12
O Outlook 2013 Problems sending large mails Using Outlook 4
Diane Poremsky Automatically create a task when sending a message New Slipstick.com Articles 0
P Categorise emails on sending - macro not working in Preview mode Using Outlook 1
Diane Poremsky Outlook is sending winmail.dat attachments New Slipstick.com Articles 0
Diane Poremsky Select from a List of Subjects before Sending a Message New Slipstick.com Articles 0
P Outlook 2010 sending safe senders email to junk box Using Outlook 8
Diane Poremsky To delay sending a message in Outlook New Slipstick.com Articles 0
D Close Oulook after sending emails via vba without outbox getting stuck. Outlook VBA and Custom Forms 1
M godaddy says my outlook's sending spam. Using Outlook 4
Similar threads


















































Top