Outlook macro that saves arrived emails attachments into a folder. want it to save in 2 placed rather than 1.
Hi,
Outlook macro that saves arrived emails attachments into a folder. want it to save in 2 placed rather than 1.
At present it saves in the below path
Const saveFolder As String = "D:\SophosMailAttachments\"
Can i also save in this path
\\servername\foldername\foldername
in the same way as now.
Regards
sharath
Sub SaveAttachment_NoStrip(ByRef mai As Outlook.MailItem)Dim objItem As ObjectDim mailAtt As AttachmentDim intAtt As IntegerDim saver As StringDim constsaver As StringDim fn As StringDim ft As StringDim Subject As StringDim del As VariantConst sendereMailTrigger As String = "India.Alert@plc.com"Const saveFolder As String = "D:\SophosMailAttachments\" On Error GoTo exitsub If LCase(mai.sendereMailAddress) <> LCase(sendereMailTrigger) Then Exit Sub If mai.Attachments.Count > 0 Then If Right(saveFolder, 1) = "\" Then constsaver = saveFolder Else constsaver = saveFolder & "\" End If constsaver = constsaver & Format(Date, "yyyy-mm-dd") & "\" md constsaver, True For intAtt = 1 To mai.Attachments.Count Subject = Replace(mai.ConversationTopic, """", " ") For Each del In Array("/", ":", "*", "?", "<", ">", "|") Subject = Replace(Subject, del, " ") Next Subject = Left(Subject, 250 - 16 - Len(constsaver)) saver = constsaver & Subject & "_" & Left(mai.Attachments.Item(intAtt).FileName, InStr(mai.Attachments.Item(intAtt).FileName, ".") - 1) & "_" & Format(Date, "yyyy-mm-dd") & "." & Right(mai.Attachments.Item(intAtt).FileName, Len(mai.Attachments.Item(intAtt).FileName) - InStr(mai.Attachments.Item(intAtt).FileName, ".")) mai.Attachments.Item(intAtt).SaveAsFile saver Next End Ifexitsub:End Sub
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
Thanks Chris that email comes in another 3 hrs..Shall check and get back
Chris Bottomley
Dont forget to modify the line:
saveFolder2
No offence intended ;o)
bsharath
ASKER
Sure
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
bsharath
ASKER
Thank U...:-)
bsharath
ASKER
Chris i have a problem..
The 2nd location where the files are saved only happens if the folder is created manually...
Can the folder also get created in the 2nd path as the 1st location