none
EWS manage api:hexadecimal value 0x01, is an invalid character RRS feed

  • Question

  • ews return this exception when save a emailmessage:

    {"'', hexadecimal value 0x01, is an invalid character."}

    StackTrace:

       at Microsoft.Exchange.WebServices.Data.EwsServiceXmlWriter.WriteValue(String value, String name)
       at Microsoft.Exchange.WebServices.Data.MessageBody.WriteElementsToXml(EwsServiceXmlWriter writer)
       at Microsoft.Exchange.WebServices.Data.ComplexProperty.WriteToXml(EwsServiceXmlWriter writer, XmlNamespace xmlNamespace, String xmlElementName)
       at Microsoft.Exchange.WebServices.Data.ComplexProperty.WriteToXml(EwsServiceXmlWriter writer, String xmlElementName)
       at Microsoft.Exchange.WebServices.Data.ComplexPropertyDefinitionBase.WritePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, Boolean isUpdateOperation)
       at Microsoft.Exchange.WebServices.Data.PropertyBag.WriteToXml(EwsServiceXmlWriter writer)
       at Microsoft.Exchange.WebServices.Data.ServiceObject.WriteToXml(EwsServiceXmlWriter writer)
       at Microsoft.Exchange.WebServices.Data.CreateRequest`2.WriteElementsToXml(EwsServiceXmlWriter writer)
       at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.WriteBodyToXml(EwsServiceXmlWriter writer)
       at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.WriteToXml(EwsServiceXmlWriter writer)
       at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.Emit(HttpWebRequest& request)
       at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(HttpWebRequest& request)
       at Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.InternalExecute()
       at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
       at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalCreateItems(IEnumerable`1 items, FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode, ServiceErrorHandling errorHandling)
       at Microsoft.Exchange.WebServices.Data.ExchangeService.CreateItem(Item item, FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode)
       at Microsoft.Exchange.WebServices.Data.Item.InternalCreate(FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode)
       at Microsoft.Exchange.WebServices.Data.Item.Save(FolderId parentFolderId)
       at ExchangeMigrationLibrary.Exchange.Migration.EmailType.Migrate() in C:\Users\zhangwei\Project\Source\ApplicationInstance\ExchangeMigrationLibrary\Exchange\Migration\EmailType.cs:line 81
       at ApplicationInstance.Form4.button8_Click(Object sender, EventArgs e) in C:\Users\zhangwei\Project\Source\ApplicationInstance\ApplicationInstance\Form4.cs:line 810
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at ApplicationInstance.Program.Main() in C:\Users\zhangwei\Project\Source\ApplicationInstance\ApplicationInstance\Program.cs:line 21
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

     

     

     


    An old bird from china,a haha...
    Friday, September 9, 2011 1:55 AM

All replies

  • Hi,

    a character of ASCII 0x01 would also be invalid on a normal RFC 822 message. Why do you want to add such a character to an email?

    If this is not your intention and the character 0x1 is there by accident, please post the code you are using.

    Kind regards,
    Henning Krause

    Friday, September 9, 2011 6:30 AM
  •             Item.Load();         
                Item newItem = Item.Bind(FolderType.Host.Service, Item.Id);

                newItem.SetExtendedProperty(new ExtendedPropertyDefinition(57, MapiPropertyType.SystemTime), Item.DateTimeSent);
                newItem.SetExtendedProperty(new ExtendedPropertyDefinition(3590, MapiPropertyType.SystemTime), Item.DateTimeReceived);
                newItem.SetExtendedProperty(new ExtendedPropertyDefinition(3591, MapiPropertyType.Integer), "1");
                newItem.Save(DestFoldId);

                I just want send the EmailMessage from one emailbox to another;

                Because the source emailMessage Body Text contain the invalid character,It will be throw a Exception when I call Item.save()

     


    An old bird from china,a haha...
    Friday, September 9, 2011 9:00 AM
  • Hi,

    Since you can successfully load the item in question I suggest you "fix" the content by removing the invalid character from the instance.

    Apart from this I remember that there was something fixed on the Exchange side related to this, but I may be mistaken and I can't find a reference to it on the web. Anyway, it's a good idea to see whether your Exchange server is fully patched, up to the latest roll-up.

    Kind regards,
    Henning rause

    Friday, September 9, 2011 9:59 AM
  • Hi:

     I have replace those invalid character by regex,but i still think there is some better way to sovle it;

     because the problem is cause by the XmlWriter.Write(),and this method have some bug with serialization.

     

     Any way,thank you very much!


    An old bird from china,a haha...
    Friday, September 9, 2011 10:04 AM
  • Hi Caney,

    no it doesn't. This is by design. 0x1 is invalid for an XML character.

    Not sure how they manage to create the XML on the server, but it's definitely wrong.

    Kind regards,
    Henning

    Friday, September 9, 2011 10:31 AM