Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Outlook VBA
Hi,
Anyone plz help me with this,(Using Outlook 2010)
i want to copy a mail(from outlook 2010 inbox) automatically from particular sender along with the subject and attachment and save that file into a specific "sharepoint folder " which needs authendication(The autendication must be static since we are using this in particular system with same user name and password).
 
Also i have to update the mail if another new mail comes with same subject.....
 
I used a coding and moved file to harddisk saved in .msg format and trying this code to move to sharepoint...... but doen't work Frown | :( i think i have to give user name and password somewhere plz help me with this................
Sub Copy_Certain_Files_In_Folder()
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
Dim FileExt As String
FromPath = "C:\mail"
ToPath = "http://sharepoint"  
FileExt = "*.msg*"  
If Right(FromPath, 1) <> "\" Then
FromPath = FromPath & "\"
End If
Set FSO = CreateObject("scripting.filesystemobject")
If FSO.FolderExists(FromPath) = False Then
MsgBox FromPath & " doesn't exist"
Exit Sub
End If
If FSO.FolderExists(ToPath) = False Then
MsgBox ToPath & " doesn't exist"
Exit Sub
End If
FSO.CopyFile Source:=FromPath & FileExt, Destination:=ToPath
MsgBox "You can find the files from " & FromPath & " in " & ToPath
End Sub
Error:
File does not exist
:(
Posted 5-Jun-12 21:54pm
Edited 6-Jun-12 1:56am
v2
Comments
Sandeep Mewara at 6-Jun-12 6:58am
   
Not clear on your issue. Error says 'File does not exists' and you are trying/asking in authentication direction.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

i got it..............
 
Public Sub Mailcopy(msg As Outlook.MailItem)
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
Dim FileExt As String
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "C:\Temp\" '<< Change
msg.SaveAs saveFolder & Format(msg.Subject, "string") & ".msg", olMSG
FromPath = "C:\Temp" '<< Change
ToPath = "\\sharepoint '<<give network path in ur harddisk not http link
FileExt = "*.msg" '<< Change if u are trying different format
If Right(FromPath, 1) <> "\" Then
FromPath = FromPath & "\"
End If
Set FSO = CreateObject("scripting.filesystemobject")
If FSO.FolderExists(FromPath) = False Then
MsgBox FromPath & "No NEW MAILS"
Exit Sub
End If
If FSO.FolderExists(ToPath) = False Then
MsgBox "LOG IN TO SHAREPOINT"
Exit Sub
End If
FSO.CopyFile Source:=FromPath & FileExt, Destination:=ToPath
MsgBox "Mail from Iniyarathi is copied to sharepoint"
Kill "C:\Temp\*.*" 'Delete the temp files
End Sub
 

 
Smile | :) Working perfectly
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 325
1 DamithSL 300
2 Sergey Alexandrovich Kryukov 289
3 CPallini 235
4 Maciej Los 215
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 8 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100