Forum Discussion
illmortal
Mar 02, 2023Copper Contributor
Automating OneNote text with format to new Outlook message
Hello, I’m getting into PS, I’d like to automate basic processes on my own PC to start. There’s a constant process I do day in and day out, wanted to eliminate all the clicking, copying, pasting,...
Varun_Ghildiyal
Mar 07, 2023Iron Contributor
# Get the text from OneNote
$onenote = Get-Clipboard -TextFormatType Html
# Create a new Outlook message
$outlook = New-Object -ComObject Outlook.Application
$message = $outlook.CreateItem(0)
# Set the message body to the OneNote text
$message.HTMLBody = $onenote
# Prompt for email address and subject
$to = Read-Host "To:"
$subject = Read-Host "Subject:"
# Set the email address and subject
$message.To = $to
$message.Subject = $subject
# Display the message for the user to review and send
$message.Display()
$onenote = Get-Clipboard -TextFormatType Html
# Create a new Outlook message
$outlook = New-Object -ComObject Outlook.Application
$message = $outlook.CreateItem(0)
# Set the message body to the OneNote text
$message.HTMLBody = $onenote
# Prompt for email address and subject
$to = Read-Host "To:"
$subject = Read-Host "Subject:"
# Set the email address and subject
$message.To = $to
$message.Subject = $subject
# Display the message for the user to review and send
$message.Display()
- illmortalMar 07, 2023Copper Contributor
Varun_Ghildiyal wow this is great! Going to test it out. Thank you, Varun!