Automating OneNote text with format to new Outlook message

New Contributor



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, typing and automate it. Taking texts in its format from OneNote, to opening a new Outlook message, pasting the text in the same format into the body of the new message. So all I’d have to do is fill in the email address and subject then click send. 

2 Replies
# 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

@Varun_Ghildiyal wow this is great! Going to test it out. Thank you, Varun!