|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Issues redirecting mail in outlook using VBA. Help greatly appreciated
Below is my script in MS Outlook 2003. I am using XP Pro and exchange server. I am trying to put together a script that will redirect all new email to my handheld device leaving a copy in my inbox. I get a runtime error each time new mail arrives pointing to the (.update) line in my code.
Error - Fields update failed, for further info, examine status property of individual field objects. Any help or direction would be greatly appreciated! Sub RedirectNewMail(MyMail As MailItem) ' Jim Boyce and Sue Mosher Dim strID As String Dim olNS As Outlook.NameSpace Dim olMail As Outlook.MailItem strID = MyMail.EntryID Set olNS = Application.GetNamespace("MAPI") Set itm = olNS.GetItemFromID(strID) ' do stuff with olMail, e.g. Set myInbox = olNS.GetDefaultFolder(olFolderInbox) Dim iMsg Dim iConf Dim Flds Dim strHTML Dim szServer Const cdoSendUsingPort = 25 'Set MessageItems = MessageFolder.Items Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") Set Flds = iConf.Fields szServer = "my domain" With Flds .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "my ip address" .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 100 .Update End With Set iMsg.Configuration = iConf ' Build HTML for message body. strHTML = "<HTML>" strHTML = strHTML & "<HEAD>" strHTML = strHTML & "<BODY>" strHTML = strHTML & "<b> This is the test HTML message body</b></br>" strHTML = strHTML & "</BODY>" strHTML = strHTML & "</HTML>" ' Apply the settings to the message. With iMsg Set .Configuration = iConf .To = "my handhelp address" 'ToDo: Enter a valid email address. .From = "itm.SenderEmailAddress" 'ToDo: Enter a valid email address. .Subject = "This is a test CDOSYS message (Sent via Port 25)" .HTMLBody = strHTML .Send End With ' Clean up variables. Set iMsg = Nothing Set iConf = Nothing Set Flds = Nothing MsgBox "Mail Sent!" ' Build the message 'iMsg.To = "c.vanderpool@tmo.blackberry.net" 'iMsg.From = itm.SenderEmailAddress ' iMsg.Subject = itm.Subject 'iMsg.Send ' Mark as read and move the message to the NL Processed folder itm.UnRead = False End Sub |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Issues redirecting mail in outlook using VBA. Help greatly appreciated |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|