VBA代码将.msg文件复制到共享点 [英] VBA code to copy a .msg file to sharepoint

查看:127
本文介绍了VBA代码将.msg文件复制到共享点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


任何人请帮助我,(使用Outlook 2010)
我想自动复制特定发件人的邮件(来自Outlook 2010收件箱)以及主题和附件,并将该文件保存到需要身份验证的特定共享文件夹"中(由于我们在特定系统中使用此附件,因此附件必须是静态的)使用相同的用户名和密码).

如果另一个新邮件带有相同的主题,我也必须更新邮件...

我使用编码并将文件移动到以.msg格式保存的硬盘上,并尝试将此代码移动到共享点……但是不起作用:(我想我必须在某处提供用户名和密码,请帮助我与此.......

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 :( 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
:(

推荐答案

我明白了............

公用子Mailcopy(msg为Outlook.MailItem)
FSO作为对象变暗
昏暗的FromPath作为字符串
昏暗的ToPath作为字符串
昏暗的FileExt作为字符串
昏暗的objAtt作为Outlook.Attachment
昏暗的saveFolder作为字符串
saveFolder ="C:\ Temp \"''<<更改
msg.SaveAs saveFolder&Format(msg.Subject,"string")&".msg",olMSG
FromPath ="C:\ Temp"''<<更改
ToPath ="\\ sharepoint"<<给出您的硬盘中的网络路径,而不是http链接
FileExt ="* .msg"''<<如果您尝试使用其他格式,请更改
如果Right(FromPath,1)< "\"然后
FromPath = FromPath和"\"
如果结束
设置FSO = CreateObject("scripting.filesystemobject")
如果FSO.FolderExists(FromPath)= False,那么
MsgBox FromPath和没有新邮件"
退出子
如果结束
如果FSO.FolderExists(ToPath)= False,那么
MsgBox登录到SHAREPOINT"
退出子
如果结束
FSO.CopyFile源:= FromPath和FileExt,目标:= ToPath
MsgBox来自Iniyarathi的邮件已复制到共享点"
杀死"C:\ Temp \ *.*""删除临时文件
结束子



:)完美工作
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



:)Working perfectly


这篇关于VBA代码将.msg文件复制到共享点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆