Sign in to follow this  
Followers 0
celestialspring

Shell Execute: Mail To

10 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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

No, mate. I am using Outlook (2007).

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

over my head mostly, but if you want to send off a mail using smtp, then check this post. it handles attachments. maybe it will give you some ideas.

http://www.autoitscript.com/forum/index.php?showtopic=23860

btw, Hi Stefan. :D

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

This one is much easier, if you just want to have an attachment.

$ourfile = "c:\try.txt"

ShellExecute("D:\Program Files\Microsoft Office\Office12\OUTLOOK.EXE", "/a " & $ourfile)

Share this post


Link to post
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
Sign in to follow this  
Followers 0