FT
10-16-2001, 03:23 PM
Can anyone help. We have added an Exchange Server 2000 server but still have an Exchange 5.5 server which on occasion gets emails. I would like to forward any mail sent to the 5.5 server to another account. I've been successful in forwarding messages by adding an Agent Script on the desired mailboxes, but I can't seem to be able to add attachments (see script below). Any ideas?
Public Sub Folder_OnMessageCreated
Dim objOutboxFolder 'Outbox Folder
Dim objMsgColl
Dim msgResponse
Dim AMSession 'Session
Dim objRecipient
Dim objCurrentMsg
Dim objAttachments, objAttachment
Dim strResult
Dim liCount
On Error Resume Next
set AMSession = EventDetails.Session
set objCurrentMsg = AMSession.GetMessage(EventDetails.MessageID,Null)
set objOutboxFolder=AMSession.Outbox
set objMsgColl=objOutboxFolder.Messages
set msgResponse=objMsgColl.Add
set objAttachments = objCurrentMsg.Attachments
If objAttachments is nothing then
strResult = "Nothing"
Elseif objAttachments.Count = 0 then
strResult = "0 Attachments"
Else
strResult = "At least one Attachment"
liCount = 0
For Each objAttachment In objAttachments
liCount = liCount + 1
msgResponse.AddAttachment = objAttachment
Next
strResult = strResult & " ==> " & CStr(liCount) & " Attachment(s)"
End If
msgResponse.Subject = "Received Mail "
If objCurrentMsg.Text <> "" and not IsNull(objCurrentMsg.Text) then
msgResponse.Subject = msgResponse.Subject & ": " & objCurrentMsg.Subject
msgResponse.Text = objCurrentMsg.Text & strResult
else
msgResponse.Text = "Unable to Read the Text"
end if
set objRecipient=msgResponse.Recipients.Add
objRecipient.Name="testemail??@hotmail.com"
objRecipient.type=1
objRecipient.Resolve
msgResponse.Update
msgResponse.Send
set objOutboxFolder = nothing
set objMsgColl = nothing
set msgResponse = nothing
set AMSession = nothing
set objRecipient = nothing
set objCurrentMsg = nothing
End Sub
Public Sub Folder_OnMessageCreated
Dim objOutboxFolder 'Outbox Folder
Dim objMsgColl
Dim msgResponse
Dim AMSession 'Session
Dim objRecipient
Dim objCurrentMsg
Dim objAttachments, objAttachment
Dim strResult
Dim liCount
On Error Resume Next
set AMSession = EventDetails.Session
set objCurrentMsg = AMSession.GetMessage(EventDetails.MessageID,Null)
set objOutboxFolder=AMSession.Outbox
set objMsgColl=objOutboxFolder.Messages
set msgResponse=objMsgColl.Add
set objAttachments = objCurrentMsg.Attachments
If objAttachments is nothing then
strResult = "Nothing"
Elseif objAttachments.Count = 0 then
strResult = "0 Attachments"
Else
strResult = "At least one Attachment"
liCount = 0
For Each objAttachment In objAttachments
liCount = liCount + 1
msgResponse.AddAttachment = objAttachment
Next
strResult = strResult & " ==> " & CStr(liCount) & " Attachment(s)"
End If
msgResponse.Subject = "Received Mail "
If objCurrentMsg.Text <> "" and not IsNull(objCurrentMsg.Text) then
msgResponse.Subject = msgResponse.Subject & ": " & objCurrentMsg.Subject
msgResponse.Text = objCurrentMsg.Text & strResult
else
msgResponse.Text = "Unable to Read the Text"
end if
set objRecipient=msgResponse.Recipients.Add
objRecipient.Name="testemail??@hotmail.com"
objRecipient.type=1
objRecipient.Resolve
msgResponse.Update
msgResponse.Send
set objOutboxFolder = nothing
set objMsgColl = nothing
set msgResponse = nothing
set AMSession = nothing
set objRecipient = nothing
set objCurrentMsg = nothing
End Sub