question

AndronikVadim-3835 avatar image
0 Votes"
AndronikVadim-3835 asked AndronikVadim-3835 answered

Sending Outlook template *.oft with inline images by powershell

Hello everyone!

I sending by powershell * .oft template, which contains pictures inline the text. For this I use comObject Outlook.Application. The recipient receives a message without pictures. The rest of the formatting is retained.
If i send this template from Outlook application, the recipient receives a valid email with inline pictures.
How to achieve saving images when sending a template by powershell?

Thanks for any suggestions

windows-server-powershell
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@AndronikVadim-3835
As your issue is out of our support scope, I would remove the tag "office-itpro". Thanks for your understanding.

0 Votes 0 ·

Use the "Code Sample" editor and post the PowerShell code you're using to do this. The "Code Sample" editor is the 5th icon from the left -- it has the graphic "101 010" as its icon.

0 Votes 0 ·

I'm using this code:


 $PathToOft = "c:\OFT\Welcome4.oft"
 $mailboxes = "user@domain.ru"
    
 $outlook = New-Object -comObject Outlook.Application 
 $mail = $Outlook.CreateItemFromTemplate("$PathToOft")
    
 foreach ($mailbox in $mailboxes){
        
     $mail.Forward()
     $mail.Recipients.Add($mailbox)
     $mail.To = $mailbox
     $mail.Save()
     $mail.send()
 }







0 Votes 0 ·

I really don't like it when someone says to remove a tag from a message and never offers either another suitable tag or a suggestion as to where to look for help.

While "office-itpro" may not be correct, I'm not sure how much credence to place on a suggestion from someone with only two posts!

I see lots of questions using the tag office-outlook-itpro related to scripting. I'd give that a try. The code you're using in PowerShell looks just like the code in many examples using VBA.

Is the message your sending being sent in HTML format? You might try setting that explicitly.

0 Votes 0 ·

1 Answer

AndronikVadim-3835 avatar image
0 Votes"
AndronikVadim-3835 answered

I have found a solution for my question.
I refused using .oft in favor of .msg. This code is working for me and saving images inline message:

 $PathToMsg = "c:\message.msg"
 $mailboxes = "user@domain.ru"
    
 $outlook = New-Object -comObject Outlook.Application 
 $session = $outlook.Session
 $session.Logon()
    
 $mail = $outlook.Session.OpenSharedItem($PathToMsg)
    
 foreach ($mailbox in $mailboxes){
     $mail.Forward()
     $mail.Recipients.Add($mailbox)
     $mail.To = $mailbox
     $mail.send() 
    
 }

Thanks all for your attention =)

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.