void HandleMailCreateTextItem(MailCreateTextItem packet) { if (!CanOpenMailBox(packet.Mailbox)) { return; } Player player = GetPlayer(); Mail m = player.GetMail(packet.MailID); if (m == null || (string.IsNullOrEmpty(m.body) && m.mailTemplateId == 0) || m.state == MailState.Deleted || m.deliver_time > Time.UnixTime) { player.SendMailResult(packet.MailID, MailResponseType.MadePermanent, MailResponseResult.InternalError); return; } Item bodyItem = new Item(); // This is not bag and then can be used new Item. if (!bodyItem.Create(Global.ObjectMgr.GetGenerator(HighGuid.Item).Generate(), 8383, player)) { return; } // in mail template case we need create new item text if (m.mailTemplateId != 0) { MailTemplateRecord mailTemplateEntry = CliDB.MailTemplateStorage.LookupByKey(m.mailTemplateId); if (mailTemplateEntry == null) { player.SendMailResult(packet.MailID, MailResponseType.MadePermanent, MailResponseResult.InternalError); return; } bodyItem.SetText(mailTemplateEntry.Body[GetSessionDbcLocale()]); } else { bodyItem.SetText(m.body); } if (m.messageType == MailMessageType.Normal) { bodyItem.SetCreator(ObjectGuid.Create(HighGuid.Player, m.sender)); } bodyItem.AddItemFlag(ItemFieldFlags.Readable); Log.outInfo(LogFilter.Network, "HandleMailCreateTextItem mailid={0}", packet.MailID); List <ItemPosCount> dest = new List <ItemPosCount>(); InventoryResult msg = GetPlayer().CanStoreItem(ItemConst.NullBag, ItemConst.NullSlot, dest, bodyItem, false); if (msg == InventoryResult.Ok) { m.checkMask = m.checkMask | MailCheckMask.Copied; m.state = MailState.Changed; player.m_mailsUpdated = true; player.StoreItem(dest, bodyItem, true); player.SendMailResult(packet.MailID, MailResponseType.MadePermanent, MailResponseResult.Ok); } else { player.SendMailResult(packet.MailID, MailResponseType.MadePermanent, MailResponseResult.EquipError, msg); } }