Comments (18)
So I just did some testing:
So it seems to work. I've not tested it with old version but after upgrading to 3.1.0 which will be used in next release (hopefully).
from mailozaurr.
Added MimeMessagePath
string which allows saving the message request if we ever need to troubleshoot it
from mailozaurr.
@jstedfast Do you have any idea what would not be stripped by [MimeKit.BodyBuilder]::new()
that we're using when it comes to new lines for text?
from mailozaurr.
I'm thinking that this may be more likely to be an issue with passing the body as a string on the command-line? I'm not sure, though.
Keep in mind that when sending a message, message bodies are ALWAYS formatted with DOS line endings (aka CRLF).
Is the body base64 encoded? That might cause issue if the input has LF instead of CRLF, but otherwise it shouldn't be an issue.
from mailozaurr.
The -Raw
switch definition:
Ignores newline characters and returns the entire contents of a file in one string with the newlines preserved. By default, newline characters in a file are used as delimiters to separate the input into an array of strings. This parameter was introduced in PowerShell 3.0.
That means it's one string with everything as is - so should be fine.
from mailozaurr.
^^ It's CRLF
from mailozaurr.
The BodyBuilder class just takes the TextBody and/or HtmlBody string property values and sets them as the Text property on a TextPart when it constructs the message body.
TextBody.Text calls SetText() which just does Encoding.UTF8.GetBytes(). There's no line-ending conversion.
Also note that SmtpClient.Send/Async() makes sure that line endings are CRLF format (mostly needed when running on Linux) since SMTP specifies line endings must be CRLF.
from mailozaurr.
In order to be sure I saved the email as TXT in Thunderbird. Send-MailMessage (upper) preserves the CRLF (and adds 3 more at the end?) compared to Send-EMaillMessage (lower) which converts it to a space (0x20)
from mailozaurr.
I can't think of anything in MimeKit/MailKit that would replace CRLF with a space.
Would it be possible to dump your message to a file (before sending via SMTP) so that we can see the raw message being sent before any other software has a chance to modify it?
Ideally it would use the MimeMessage.WriteTo() method.
from mailozaurr.
I'm not a programmer and would need guidance on that.
from mailozaurr.
Basically just about here:
Mailozaurr/Public/Send-EmailMessage.ps1
Line 684 in 5aeaf9d
You would need to do:
$Message.WriteTo($PathToFile)
So you either modify the module a bit, reimport it with Import-Module -Force and try again or I guess we could add some sort of debug method to Mailozaurr.
from mailozaurr.
Here's the code responsible for using BodyBuilder to build HTML/Text and then assign that Body to $Message.Body
Mailozaurr/Public/Send-EmailMessage.ps1
Lines 549 to 561 in 5aeaf9d
from mailozaurr.
Looks promising - and sorry that I was not yet able to get the dump. During week time I hardly have time for such things and my plan was to deal with it on the upcoming Saturday. But now I wait for the next release.
from mailozaurr.
@stethos give new version a try
from mailozaurr.
Sorry, still not working for me in my email client (Outlook and Thunderbird)
from mailozaurr.
what if you use the example, with the file i prepared that's on github?
from mailozaurr.
Ohhh, you're using body.... that's for HTML, you should use Text :-)
$Text = Get-Content -Path "$PSScriptRoot\Input\Test.txt" -Raw
# this is simple replacement (drag & drop to Send-MailMessage)
Send-EmailMessage -To '[email protected]' -Subject 'Test' -Text $Text -SmtpServer 'smtp.office365.com' -From '[email protected]' -Priority High -Credential $MailCredentials -UseSsl -Port 587 -Verbose
Text property takes text, body takes HTML. I am not able to distinguish between HTML and text in easy way, so I expose two options. Also you can provide both - so when HTML is disabled, text shows up AFYIK.
from mailozaurr.
Gosh, -Text works like a charm!
Did not think about this one as I just replaced the SendMailMessage by SendEMailMessage withoug digging more deeply into every parameter.
Thank you for all your help and time you have spend on that one.
from mailozaurr.
Related Issues (20)
- How to specify 'Encoding' when sending mail using '-graph' HOT 3
- FIlename containing ie round brackets dont show correctly in attachment
- Small problem with Email-name
- Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe HOT 3
- how to correctly download attachment HOT 7
- Is there any way how to get path to email item ? HOT 1
- MX Record IPAddress with -Separate HOT 5
- Get 403 after using Send-EmailMessage HOT 6
- From field should be mandatory
- If Path doesn't exists, an error occurs (attachments) HOT 1
- How to delete mail from IMAP ?
- Adapting "from" with custom name HOT 1
- Can't send attachment > 3Mb using Graph HOT 2
- SkipCertificateValidation => wrong naming HOT 2
- Feature Request: SkipCertificateCheck on Connect-IMAP/Connect-POP3
- Logging HOT 5
- Cannot update Mailozaurr 1.0.2 - not trusted any longer HOT 2
- -AttachSelf option like in Emailimo HOT 1
- -SkipCertificateValidatation does not seem to work HOT 2
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 mailozaurr.