Comments (3)
Hi,
the problem is with all email address headers (from, to, cc).
I made a similar fix as you did:
private object TransformAddress(MailAddress address)
{
var headersEncoding = MailMessage.HeadersEncoding ?? Encoding.UTF8;
if (headersEncoding.Equals(Encoding.ASCII) || address.DisplayName.Trim() == "")
return address;
return GetEncodedAddress(address, headersEncoding);
}
private string GetEncodedAddress(MailAddress address, Encoding encoding)
{
var encodingName = encoding.BodyName.ToLower();
return "=?" + encodingName + "?B?" + TransferEncoder.ToBase64(encoding.GetBytes(address.DisplayName)) + "?=" + " <" + address.Address + ">";
}
And then calling this when adding headers:
buf.Append(TransformAddress(MailMessage.From)); ... buf.Append(TransformAddress(MailMessage.To[0])); ... buf.Append(TransformAddress(MailMessage.To[x])); ... buf.Append(TransformAddress(MailMessage.CC[0])); ... buf.Append(TransformAddress(MailMessage.CC[x]));
from aim.
Hi @boskoKlemenc,
You are right. Currently, in my MUA software that uses this project, just permits use the “display name” property in the “from” field. But also should be able used in any mail address field…
Although, the real problem here is not forcing the use of MimeMailAddress in front of System.Net.Mail.MailAddress. Then it would only be necessary to override the ToString() method. At this time, both classes are mixed along the code and in the client also can be use both. For making this in a good way, should be necessary to hide and override some methods in MimeMailMessage class. But I think this would produce many other changes and things to check. So for the moment, just will refactor my code similarly. Thanks for your reply.
from aim.
from aim.
Related Issues (20)
- Content-Type text/html not set [sf#11] HOT 1
- How to use custom formatted HTML body [sf#12] HOT 4
- Sending Emails on TLS 1.2 [sf#13] HOT 4
- End of line characters, /r/n, in email body get converted to white space. [sf#14] HOT 1
- Need support for alternateviews [sf#15] HOT 4
- Error when adding attachment [sf#16]
- Email not send if attachment used [sf#17] HOT 5
- SmtpSocketClient NullReferenceException on TestConnection() method
- Error 554 line too long at various providers if an attachment is sent HOT 1
- From Response :250 2.1.0 OK d17sm11257454wrg.26 - gsmtp Sent Response :Error in reading response from server. Unable to read data from the transport connection: Connection timed out. HOT 1
- Delemiter when using multiple to/cc/bcc recipients
- Message-Id Header HOT 1
- Non async call
- Cannot use package on .NET 7 VS 2022 HOT 1
- Support large attachments [sf#6]
- Be able to use streams as attachments [sf#7]
- Conversion of System.Net.Mail.Attachment objects to the MimeAttachment type. [sf#8]
- Add support for mono [sf#9] HOT 1
- Date and Time Issues [sf#10] HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aim.