📜 ⬆️ ⬇️

We send letters from Mail.app with the correct formatting

If you use Apple Mail and send letters in HTML format, you may have noticed that the recipients of your letters have a text font that is not the one you set in the settings. The reason for this disgrace is simple - Mail.app does not indicate the font in the sent HTML text, and the font set in the settings is used only when creating your letters or viewing others, if the font is not specified in them either. As a result, the program that receives the letter displays it on the screen in the font that it deems necessary to use. Those who use Microsoft Outlook, where the default font is Times New Roman, 12 points, your letters will look especially sloppy. There may be various reasons for not wanting to be reconciled with this state of affairs - from simple aesthetic to the need to follow corporate standards.

The simplest, but not the most convenient solution is to manually set the font each time. My will power is not enough. If you don’t see any problems with this, you can stop reading.

The second option is to create an automatic signature with the desired font, so that it has a few empty lines at the beginning, and write inside this signature. Unfortunately, there are problems with this option: for some reason, glitches with font size occur regularly.
')
You can, of course, use another program. But if you like Mail.app, then all is not lost for you: under the cut, I'll tell you about another option that seemed to me the most successful.

We will use the function of creating letters on the basis of the form (Stationery). If you have never used it, then create a new letter and click on the button “Show form” on the toolbar of the new letter. A list of the forms supplied with Mail.app will appear. When you choose a form, a beautiful template appears in which you can insert your pictures and text.

We need to create our own template. Mail stores the templates in the / Library / Application Support / Apple / Mail / Stationery / Apple / Contents / Resources directory. There are folders corresponding to the various categories of forms. You can choose any, for definiteness, take the folder Announcements. Going inside, we will find the folder Contents, and then - Resources.

When you open this folder, you will see, among other things, folder-bundles with the extension ".mailstationery", marked with white icons depicting envelopes. We need to create the same package. To do this, create a directory, and call it to your liking, for example, “mymail.mailstationery”.

The system will immediately display it as a package. We go in the package by sticking it with the right mouse button (or Control + click) and selecting “Show package contents” from the local menu. In it we create the folder “Contents”, and in this folder we create the folder “Resources”.

Now we need to create several files and another folder. First, create the folder “English.lproj”, and in it we will create one text file with the name “DisplayName.strings”. It is not necessary to create such a file from scratch, you can get it in any other similar package, and then edit it slightly. Actually, there is only one line in the file:

"Display Name" = "My Mail";

It sets the name that will be assigned to your form. Instead of "My Mail" you can put whatever you want.

Next we need to create three more files in the Resouces directory. The most important is actually the HTML template. The file is called content.html. First, put something like this into it:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
< html >< head >
< title > Formal </ title >
</ head >

< body style ="margin: 10px; padding: 0pt; background: rgb(255, 255, 255)" >
< div class ="body-content" id ="body-content" >
< font style ="font-size: 13px;" color ="#000000" face ="Tahoma, Arial, Helvetica, sans serif" >
< span contenteditable ="true" apple-content-name ="body" style ="display: block; width: 600px" > < br ></ span >
</ font >
</ div >
</ body >
</ html >




In the future, you can change everything to your liking, including, perhaps, you want to add a signature. The fact is that if a letter is created on the basis of a form, then the usual mechanism for adding a signature to it does not work.

The second file is called "Description.plist". Here are its contents:
<? xml version ="1.0" encoding ="UTF-8" ? >
<! DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
< plist version ="1.0" >
< dict >
< key > Background Images </ key >
< array />
< key > Composite Images </ key >
< array />
< key > Folder Name </ key >
< string > mymail.mailstationery </ string >
< key > HTML File </ key >
< string > content.html </ string >
< key > Images </ key >
< array >
</ array >
< key > Stationery ID </ key >
< string > 52CF436E-68DA-4842-A638-2B912C5F7322 </ string >
< key > Thumbnail Image </ key >
< string > thumbnail.png </ string >
</ dict >
</ plist >



And the last file should be called thumbnail.png. By the way, apparently, only png and jpeg files are supported in forms, so do not try to use, for example, gif. It is best to take this file from some other form, and, if you wish, edit it.

Now we have everything we need. The last detail remains: to create new letters was convenient, there must be a quick way to create letters based on the form. And there is such a way: an attempt to open a form package created by us in Finder leads to the creation of an empty letter based on this form. Therefore, I recommend dragging the package “mymail.mailstationery” created by us to the right side of the Dock, to the left of the basket. Then the function of creating a new letter will always be at hand, even when the main Mail.app window is closed or minimized.

Ergonomically, the process will be slightly different from the usual: you have to poke the mouse in the upper left corner of the new letter window so that the cursor appears and the text field opens.

If you want to add some pictures (for example, a company logo), then copy the graphic file to the same “Resources” directory in jpeg or png format, paste the link to it into the HTML template file and remember to include the name of this file in Description .plist. After this, the Images section of this file will look like this:

< key > Images </ key >
< array >
< string > my_logo.png </ string >
</ array >



I checked this method with various mail programs, including MS Outlook, everything works as it should.

Source: https://habr.com/ru/post/111810/


All Articles