How to edit the subject of an email I received in mutt's mailbox list? - mutt

Everything is in my title. I received an header with a huge typos that I want to keep in my mailbox for a while, but it is really unpleasant to read this mistake over and over. So I would like to edit it. Command "e" lets me edit the body of the email, not the subject. So of course I am not interested in the "s" (edit-subject) command used in compose mode.

Normally the <edit> command, bound to e lets you edit the complete raw message, including all headers.
From the documentation:
<edit> (default: e)
This command (available in the index and pager) allows you to edit the raw
current message as it's present in the mail folder. After you have finished
editing, the changed message will be appended to the current folder, and
the original message will be marked for deletion; if the message is
unchanged it won't be replaced.
I tried unsetting edit_hdrs and all headers are still there for editing.

Related

cfapi: CfDehydratePlaceholder seems to be stucked

My target is, that files can be hydrated or dehydrated on user request via the Explorer "free up space" or "Always keep on Device" ContextMenu entry. In case I create a new placeholder file that is dehydrated from the beginning, everything works and I can hydrate it via the callback mechanics. But the way around does not work for me. Inside of the Explorer the file will be marked as UnPinned and the file will be marked as syncing, but my application does not receive any callback from CF_CALLBACK_TYPE_NOTIFY_DEHYDRATE or CF_CALLBACK_TYPE_NOTIFY_DEHYDRATE_COMPLETION. Then I wanted to do it manually with CfDehydratePlaceholder, but exactly the same behaviour. Nothing happens and the file remains in the state, syncing. Even if I used CfSetInSyncState to set the state to CF_IN_SYNC_STATE_IN_SYNC it remains to be in the state syncing.
Now I wanted to implement a minimal example with the help of Cloud Mirror Example, but I realized it has the same behaviour. When I try to dehydrate a file again exactly the same happens there as well. From my perspective, it feels for me like cfapi expects an ack from the cloud service, which it never gets.
But in OneDrive everything works like expected. What I am missing? Did I have to set some specific settings?
I had a misunderstanding of the whole API and here is how I understand the API now, to help other people, who are struggling with it.
You have to register your sync root and connecting your app to it. In case of connecting it, you will receive a CF_CONNECTION_KEY, which is needed to communicate with the virtual filesystem. Then you can add extended attributes to all files inside of your sync root. The most important are custom attributes you can choose by yourself to identify the file object by your app if needed and then the PinState and SyncState. Mostly the SyncState don't have to be changed by the app, besides marking a file as synced after it was processed by the app. (you can do it at the moment you update your custom attributes) Because in case a file changed, the SyncState will automatically be changed. The PinState declares which final state a file should have. For example UNPINNED means, that the file should be dehydrated, and PINNED the opposite. It does not mean, that the file necessarily has already this state. My misunderstanding was, that I thought in case I unpinned a file, it will be automatically dehydrated. Or in case I pinned a placeholder I will receive a request via the callback function I mentioned in my question. But this is not the case. Your app needs to find out via a FileWatcher (i can recommend my own created FileWatcher project: https://github.com/neXenio/panoptes) that the file attribute of specific files was changed. Then your app has to process every step. Like already mentioned in case of dehydrating, the app needs to call CfDehydratePlaceholder. In case of hydrating, you need to open a transfer session via CfGetTransferKey and then hydrate (send the data to the empty file) via the method CfExecute, where you need the connection key and the transfer key. And that's are the basics. There is much more to tell about it, but I guess with this beginning, everybody can figure it out by himself.

Embedded graphics in original mail change to attached graphics in reply when using exchangelib in python

We have a python script that replies to incoming emails using exchangelib. User A sends us an email that can contain a picture/graphic (e.g. company logo in signature line). Our script is able to reply to his mail, and user A will get our reply. Unfortunately, the picture/graphic that was embedded in the original mail to us, is now an attached file instead of an embedded picture.
Here is the code that we're using:
origmsg.reply(
subject='Re: ' + origmsg.subject,
body="This is my reply to your inquiry...."
)
I understand that for new messages the HTML code needs to include a reference to the attached file to make it embedded. How can this be done in a reply?
Thanks.
https://ecederstrand.github.io/exchangelib/#attachments has some example of embedding images in emails.
The .reply() method is for simple replies. You may need to call .create_reply() instead and edit the returned ReplyToItem object as needed before calling .send() on it.
If you have even more special requirements, you can call .save() on the ReplyToItem object to save it as a draft, fetch the draft as a plain Message object with account.drafts.get(id=reply_to_item_id) and do whatever you need to do before sending the draft.

How can I add a new message in the mavlink protocol?

I'm new in Mavlink, I want to add a new message in the Mavlink protocol and send it each second periodically. How can I do it?
Here you can find detailed steps about how to add new message to mavlink protocol and how you handle it.
Ensure you have the latest ArduPilot code and Mavproxy installed.
Decide what type of message you want to add.
Add the new message definition to the common.xml or ardupilotmega.xml file in the mavlink submodule.
Add functions to the main vehicle code to handle sending or receiving the command.
It depends on what autopilot you are using. If you're using ardupilot then you would need to add a new xml message definition in ardupilot/modules/mavlink/message_definitions/v1.0/ardupilotmega.xml.
You can look at the other messages to see how it should be formatted. Just make sure you choose an id that is unused.
Next you need to decide how to put this in the code. You could place it in the data_stream_send task by adding the message id to, say, STREAM_EXTRA3. This will send your message as often as the other data is sent there. As part of that you will need to define the function to actually pack your data structure using the function generated by pymavgen, the message id and enumerations. This is what I have done in my own project for ASH_DATA. You can see the changes I've made in my repository for reference. Note that some of those include changes to incorporate reception of ash data on the pixhawk and adding the data to a log file.
Given that you want to run this once a second you may want to add to the one_second_loop task or create your own task that simply calls the try_send_message function using your new message id.
You will of course need to incorporate the new message in your gcs so you can actually receive it, but that's another matter.
Hopefully this can nudge others in the right direction who are trying to do the same.

No categories in Windows Event Log

I have created a category file to the Event Logger, but the category names do not show up in Event Logger.
If I however open the log from C:\Windows\System32\winevt\Logs, the category names show up. The category name also show up if I use following PowerShell.
$eventlog = New-Object System.Diagnostics.EventLog("MyLog")
Write-Host $eventlog.Entries[0].Category
The .mc file looks like this:
MessageIdTypedef = WORD
LanguageNames=(
English=0x0409:MSG00409
Swedish=0x041D:MSG0041D
)
MessageId=1
SymbolicName=CAT_1
Language=English
Category 1
.
Language=Swedish
Kategori 1
.
MessageId=2
SymbolicName=CAT_2
Language=English
Category 2
.
Language=Swedish
Kattegori 2
.
; // Up to 22 categorys
In the registry, I have following:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\MyLog\MySource]
"CategoryCount"=dword:00000016
"TypesSupported"=dword:00000007
"CategoryMessageFile"="C:\\path\\Messages.dll"
I have found https://social.msdn.microsoft.com/forums/windowsdesktop/en-us/3fed3069-ce0f-4168-8132-4d19d66fdd7e/windows-7eventlog-creating-custom-categories with the same problem, but no answer to the problem.
I have tried this in both Windows 7, 8 and Windows Server 2008 R2
Edit
I have created a test project to show what I have done. download it here
Try adding the machine's Authenticated Users or Users group to the message folder's security level. Keep the default permissions. Then either reboot or try to restart the EventLog service.
At an administrator command prompt: net stop eventlog
You will likely be prompted to shutdown other services. You must enter Y to continue. The services being shutdown will normally restart on their own so you just need to wait a few seconds. The eventlog service may fail to shutdown because another service has restarted, it may take a couple of tries to get everything down. Watch the resulting text closely for status.
I ran into this same issue while pointing the source registry information to my message folder in my VS project. I found that it started to work after I created a C:\Test folder with an admin user and referenced that instead. The only difference between this and the project folder was the two groups. Adding either of the two groups made things work. Taking them both away from either folder made it stop.
I also found that if I had matching MessageId's in my CategoryMessageFile and my EventMessageFile it ignored the CategoryMessageFile.
Another possibility, though obviously not the OP's issue (or language), that exhibits similar symptoms is when the EventMessageFile and the CategoryMessageFile have overlapping MessageIds. I am assuming this is a bug in the event log viewer utility when looking at a 'live' source, as the symptoms do not exist when using powershell, .NET, or directly opening the event log file in Event Viewer to parse the event logs.
In my situation, I have a .NET application and am using .NET APIs to create the event source using EventSourceCreationData to specify the CategoryResourceFile and CategoryCount. By default, the MessageResourceFile will be set to C:\Windows\Microsoft.NET\Framework\v4.0.30319\EventLogMessages.dll. The effect of these APIs causes the creation of the appropriate registry keys CategoryMessageFile, CategoryCount, and EventMessageFile. Important to note here is the message file from .NET helpfully adds messages from 0x0 to 0x000FFFF that are all defined as %1\r\n\x00 - essentially meaning when you create an event message in the default way, using EventLog.WriteEntry you see the string message that was logged regardless of the event id. If instead you use EventLog.WriteEvent, you pretty much need to use a specialized messages file (see docs on the EventInstance class). More Info
The symptoms are when looking at the live Event Viewer the Category as defined with the MessageId that was passed into the event log shows up as the integer instead of the string from the resource file. Note this is different behavior from if you had misconfigured the category resource file, permission issues, etc where you see the 'Task Category' as the integer but in parenthesis.
So for example, if you specified category id 8 and are expecting the localized category name 'My Category' the Event Viewer can show one of three things: (8) meaning the CategoryMessageFile or CategoryCount registry keys are misconfigured or there is a problem with the dll. My Category if everything is working as expected. 8 if you hit the issue I am describing.
Thanks to Rich Shealer's answer for the pointer. The problem is rather than getting the Category string from the CategoryMessageFile as one would expect, it is getting it from the MessageResourceFile - and since the .NET resource file merely is a formatting string that returns the first element of source data the numeric category id is generated.
There is no 'good' workaround, but in my use case of using metadata provided to log messages via a logging framework, and some filtering, messages generally have category and event id of zero, except for where I want to specifically set one when logging for a small subset of log messages. This means the logging framework is what is calling the APIs to write the log entries. A workaround is to declare MessageId of 0x0 to be %1 in the .mc file, and only start your event ids at a number higher than the number of categories you expect to have. Then configure the EventMessageFile in the registry or via the property MessageResourceFile to first specify the category file, the semicolon delimiter, then the .NET default resource file. This will properly show and messages logged with 0's for event id and category id, and for event ids greater than your category file the same behavior you previously had. However, any eventid with a number defined that conflicts with the category - well, you get the category name as the log message. You could also remove the message resource file but then you get the annoying 'resource cannot be found' message. I confirmed the behavior here but refuse to do this - will live with the missing text, as I mostly use APIs for analysis and it is correct there.
Sadly, I can't locate any open issue with the Windows Event Viewer - I see it broken in Windows 10 build 1909.

How do you configure the email settings in CrashRpt to send the crash dump?

After reading this discussion and this discussion about using CrashRpt to generate a crash dump and email it to the developers, I've been having a difficult time finding any instructions/tutorials for configuring the email settings used by the library to send the email.
When you call the install() function to initialize CrashRpt, you specify the email address you want the crash dump sent to, but how does the CrashPrt library know how to send the email to that address? Wouldn't the library have to know the email client settings for each individual user?
When a fatal crash occurs in my code, the CrashRpt dialog box pops up and when I enter my email address and click the send button, it takes me to a "Save File" dialog box where I can save the zipped package and the account specified in the Install() function never receives an email.
Thanks in advance for any and all help! I'm clearly missing something.
What CrashRpt does for emailing:
The email system simply uses MAPI to send your email. Which would try to use your default mail client if you have one, and if it supports MAPI. Take a look at MailMsg.cpp for details.
Personal experience:
In my company's usage of CrashRpt, we modified it a bit though to call a web service that we created which submits the crash report. So we gutted the emailing code completely from CrashRpt. And instead we have in our bug tracking system a section for crashes that were auto submitted when crashes happen.
To find your problem:
I would maybe try to debug the CrashRpt code to see why it's giving you a save dialog. It should instead just open your default mail client. Maybe you have an older version of the library, or maybe the dialog resources are a little messed. Debugging the code will tell you this though.
Most likely MailReport is being called but is failing.
Set a breakpoint in the original CrashRpt code's CrashHandler.cpp at just after the DoModal:
mainDlg.m_pUDFiles = &m_files;
if (IDOK == mainDlg.DoModal())
{
//Put breakpoint here <---------
if (m_sTo.IsEmpty() ||
!MailReport(rpt, sTempFileName, mainDlg.m_sEmail, mainDlg.m_sDescription))
{
SaveReport(rpt, sTempFileName);
}
}
Check to see why MailReport is not getting called. It's either the dialog resource, or your m_sTo is not filled or you can step through MailMsg.cpp and see where MAPI is failing.
Alternate solution:
An easy fix, if you find above that MailReport is being called, but not succeeding, is to instead just do a ShellExecute and specify a mailto:
You could even try to use the MAPI method, but if that fails to do a mailto:
You can find the CrashRpt documentation, FAQ and download a new CrashRpt v1.1 here http://code.google.com/p/crashrpt/