Jump to content

Shell Execute: Mail To


Recommended Posts

Hi Guys,

Please see the code below and advice what am I doing wrong:

I want to use a variable in the command.

$ourfile = "c:\pdf\" & "$newname"
ShellExecute("mailto:test@test.com?subject=" & $ourfile & "&body= Please see attachment&attachment=""" & $ourfile & """","","","",0)

Thanks.

Cs

Hi,

I'm not quite sure. It seems that you want to send with Outlook express. There's a limitation, that you can't attach files with mailto with OE.

You may google.

;-((

Stefan

Link to comment
Share on other sites

I am not sure what error you are getting. However, I once had issues with Outlook sending messages because of the security settings. It does not like when a foreign program attempts to send an email because it looks like a virus. I used the Redemption DLL (search the net for this - its free) to tell Outlook that the message was safe. This worked.

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

No, the error is that its not attaching the attachment with the new message.

Hi,

try this:

CreateMailItem()
Func CreateMailItem()
    Local $olMailItem    = 0
    Local $olFormatRichText = 3
    Local $olImportanceLow   = 0
    Local $olImportanceNormal= 1
    Local $olImportanceHigh  = 2

    $oOApp = ObjCreate("Outlook.Application")
    $oOMail = $oOApp.CreateItem($olMailItem)

    With $oOMail
        .To = ("to@domain.com")
        .Subject = "email subject"
        .BodyFormat =  $olFormatRichText
        .Importance = $olImportanceHigh
        .Body = "email message"
        .Attach = "myfile"
        .Display
        ;.Send
    EndWith
EndFunc

You may have to change $oOApp = ObjCreate("Outlook.Application") to $oOApp = ObjCreate("Outlook.Application.12")

;-))

Stefan

Edited by 99ojo
Link to comment
Share on other sites

Hi,

this is running with Outlook 2003.

You may have to change $oOApp = ObjCreate("Outlook.Application") to $oOApp = ObjCreate("Outlook.Application.12")

Global $file = "c:\j.txt"
CreateMailItem()
Func CreateMailItem()
    Const $olByValue = 1
    Local $olMailItem    = 0
    Local $olFormatRichText = 3
    Local $olImportanceLow   = 0
    Local $olImportanceNormal= 1
    Local $olImportanceHigh  = 2

    $oOApp = ObjCreate("Outlook.Application")
    $oOMail = $oOApp.CreateItem($olMailItem)

    With $oOMail
        .To = ("to@domain.com")
        .Subject = "email subject"
        .BodyFormat =  $olFormatRichText
        .Importance = $olImportanceHigh
        .Body = "email message"
        .Attachments.Add ($file, $olByValue , 1)
        .Display
        ;.Send ; doesn't work for security reason
    EndWith
EndFunc

;-))

Stefan

Link to comment
Share on other sites

Hi,

this is running with Outlook 2003.

You may have to change $oOApp = ObjCreate("Outlook.Application") to $oOApp = ObjCreate("Outlook.Application.12")

Global $file = "c:\j.txt"
CreateMailItem()
Func CreateMailItem()
    Const $olByValue = 1
    Local $olMailItem    = 0
    Local $olFormatRichText = 3
    Local $olImportanceLow   = 0
    Local $olImportanceNormal= 1
    Local $olImportanceHigh  = 2

    $oOApp = ObjCreate("Outlook.Application")
    $oOMail = $oOApp.CreateItem($olMailItem)

    With $oOMail
        .To = ("to@domain.com")
        .Subject = "email subject"
        .BodyFormat =  $olFormatRichText
        .Importance = $olImportanceHigh
        .Body = "email message"
        .Attachments.Add ($file, $olByValue , 1)
        .Display
        ;.Send ; doesn't work for security reason
    EndWith
EndFunc

;-))

Stefan

Works great. Thank you.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...