0

I'm trying to create a link that is clickable, so that the e-mail program opens when the link is clicked. I found some information on how to do this here, but it's tailored to C#.

So far I have a Panel and the actual LinkLabel. But I don't know how to make the event happen that the e-mail client opens up:

Code:

    # Panel X: About
    $PanelAbout = New-Object System.Windows.Forms.Panel
    $PanelAbout.Location = $PanelLocation
    $PanelAbout.Size = $PanelSize
    $PanelAbout.TabIndex = 8
    $PanelAbout.BackColor = $PanelBackColor
    $PanelAbout.BorderStyle = 'Fixed3D'
    $Form.Controls.Add($PanelAbout)

    $PanelAboutLinkLabel = New-Object System.Windows.Forms.LinkLabel
    $PanelAboutLinkLabel.Location = New-Object System.Drawing.Point(8,8)
    $PanelAboutLinkLabel.Size = New-Object System.Drawing.Size(300,20)
    $PanelAboutLinkLabel.DisabledLinkColor = 'Blue'
    $PanelAboutLinkLabel.VisitedLinkColor = 'Red'
    $PanelAboutLinkLabel.LinkBehavior = 'HoverUnderline'
    $PanelAboutLinkLabel.LinkColor = 'Navy'
    $PanelAboutLinkLabel.Text = [email protected]
    $PanelAbout.Controls.Add($PanelAboutLinkLabel)

Thank you for your help.

1 Answer 1

3

You can invoke the add_Click event, and within the event invoke [system.Diagnostics.Process]::start("mailto:[email protected]") which should do the trick, like this:

$PanelAboutLinkLabel.Text = "[email protected]"
$PanelAboutLinkLabel.add_Click({[system.Diagnostics.Process]::start("mailto:[email protected]")})

There is a nice example of this here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.