メールアドレスに応じてメール添付ファイルをフォルダに保存するVBAマクロを作成しようとしています。たとえば、[email protected]からの添付ファイルを受信して電子メールで送信する場合は、その添付ファイルを \ server \ home \ joey に保存するか、[email protected]から添付ファイルを保存する必要があります \ server \ home \ steve。添付ファイルをネットワーク上の場所に保存する
最後に、保存されたファイルの名前の返信メールを送信します。私が欲しいものをほとんど実行するコードをいくつか見つけましたが、それを修正するのが難しいです。これはすべてOutlook 2010で行われています。これが私がこれまで行ってきたことです。どんな助けがあれば幸いです。
Const mypath = "\\server\Home\joe\"
Sub save_to_v()
Dim objItem As Outlook.MailItem
Dim strPrompt As String, strname As String
Dim sreplace As String, mychar As Variant, strdate As String
Set objItem = Outlook.ActiveExplorer.Selection.item(1)
If objItem.Class = olMail Then
If objItem.Subject <> vbNullString Then
strname = objItem.Subject
Else
strname = "No_Subject"
End If
strdate = objItem.ReceivedTime
sreplace = "_"
For Each mychar In Array("/", "\", ":", "?", Chr(34), "<", ">", "|")
strname = Replace(strname, mychar, sreplace)
strdate = Replace(strdate, mychar, sreplace)
Next mychar
strPrompt = "Are you sure you want to save the item?"
If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then
objItem.SaveAs mypath & strname & "--" & strdate & ".msg", olMSG
Else
MsgBox "You chose not to save."
End If
End If
End Sub
ご協力ありがとうございます。 –