WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Forwarding Email Messages


;   SentOnBehalfOfName Property
;           
;   Returns a String indicating the display name for the intended sender of the mail message. 
;   This property corresponds to the MAPI property PR_SENT_REPRESENTING_NAME. Read/write. 
;   
;   expression.SentOnBehalfOfName
;   
;   expression    Required. An expression that returns a MailItem object. 


;   You can give this a try. You'll have to edit it so that:

;      1. It goes to the correct folder  THIS ONE GOES TO THE INBOX...
;      2. You supply the correct DISPLAY NAME for the person/account you're sending
;      on behalf of (you have to have permissions for the mailbox).

;      You can modify this to "monitor" an intermediate folder, and as long as there
;      are mail messages in it, it'll forward them...

objOutlook = ObjectOpen("Outlook.Application")
mapi = objOutlook.GetNameSpace("MAPI")

For m = 1 To mapi.folders.count
;   message("Debug", mapi.folders(m).name)
   If StrIndexNC(mapi.folders(m).name, "Personal Folders", 1, @FWDSCAN)
      MainFolder = mapi.folders(m)
      For s = 1 To MainFolder.folders.count
         SubFolder = MainFolder.folders(s)
         If StrIndexNC(SubFolder.name, "Inbox", 1, @FWDSCAN)
            While SubFolder.items.count
               ThisItem = SubFolder.items(1)                   ;<-- always work with first item
               ThisItem.SentOnBehalfOf = "Display Name"        ;<-- enter the DISPLAY NAME of the mailbox

               Message(ThisItem.subject, StrCat(ThisItem.SenderName, ThisItem.SentOnBehalfOf))

               ThisItem.Save      ;<-- save the changes
               ThisItem.Forward   ;<-- forward it and the .count decrements... and the next one moves to .items(1)
            EndWhile
         EndIf
      Next
   EndIf
Next

ThisItem   = 0
SubFolder  = 0
MainFolder = 0
mapi       = 0
objOutlook = 0

Exit

Article ID:   W17195
File Created: 2007:07:03:14:28:42
Last Updated: 2007:07:03:14:28:42