Sign in to follow this  
Followers 0
Michel Claveau

email with CDO

11 posts in this topic

Hi ! Bonsoir !

I had see a script for send email with Blat.

J'ai vu, récemment, un script pour envoyer un e-mail avec Blat.

Idea : the same thing, with CDO (part of Windows).

Cela m'a donné l'idée de faire la même chose avec CDO (intégré à Windows).

Here, the code (need AutoIt beta, for COM):

Ci-dessous, le code (il faut AutoIt bêta, pour avoir COM) :

#include <GUIConstants.au3>

GUICreate("Email (by CDO)", 400, 350)

$posv=10

$posv+=25
GUICtrlCreateLabel ("TO:", 12, $posv+3, 100, 100, -1, -1) 
$TO = GUICtrlCreateInput ("", 80, $posv, 300, 20)

$posv+=25
GUICtrlCreateLabel ("FROM:", 12, $posv+3, 100, 100, -1, -1) 
$FROM = GUICtrlCreateInput ("", 80, $posv, 300, 20)

$posv+=25
GUICtrlCreateLabel ("SUBJECT:", 12, $posv+3, 100, 100, -1, -1) 
$SUBJECT = GUICtrlCreateInput ("", 80, $posv, 300, 20)

$posv+=25
GUICtrlCreateLabel ("BODY:", 12, $posv+3, 100, 100, -1, -1) 
$BODY = GUICtrlCreateInput ("", 80, $posv, 300, 150, $ES_MULTILINE)

$posv+=155
GUICtrlCreateLabel ("Attachment1:", 12, $posv+3, 100, 100, -1, -1) 
$ATTACHMENT = GUICtrlCreateInput("", 80, $posv, 300, 20)

$posv+=45
$CLOSE = GUICtrlCreateButton ("CLOSE", 100, $posv, 75, 20)
$SEND = GUICtrlCreateButton ("SEND", 250, $posv, 75, 20)

GUISetState() 


While 1
    $msg = GUIGetMsg()

    Select
        Case $msg = $GUI_EVENT_CLOSE 
            ExitLoop

        case $msg = $CLOSE 
            ExitLoop 

        Case $msg = $SEND 
            Envoi()
EndSelect

Wend
exit


Func Envoi()
            $mel=ObjCreate("CDO.Message")
            $mel.From=GUICtrlRead($FROM)
            $mel.To=GUICtrlRead($TO)
            $mel.Subject=GUICtrlRead($SUBJECT)
            $mel.Textbody=GUICtrlRead($BODY)
            $att=GUICtrlRead($ATTACHMENT)
            if stringlen($att)>0 then
                    $mel.AddAttachment($att)
            endif
            $mel.Send()
            msgbox(0,"Mail","sended.")
EndFunc

Share this post


Link to post
Share on other sites



The only problem is that the AddAttachment method requires the full path to the file (unlike vbscript), if it is only a relative path, the @WorkingDir macro must be used...


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

Hi !

Thanks, for the return's infos...

;)

Share this post


Link to post
Share on other sites

Hi !

Perhaps:

- a field needed is empty?

- your SMTP need User+Password?

- rights on CDO in too low? Are you administrator?

- you are no connect to Internet?

- have you a firewall who block CDO?

Or other reason that I don't know...

I had used the script on only four computers, all on win-XP

Have you try with WSH? Or VBscript?

For info, I use also Wscite ; but in French, with a config "house".

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hi !

Perhaps:

- a field needed is empty?

- your SMTP need User+Password?

- rights on CDO in too low? Are you administrator?

- you are no connect to Internet?

- have you a firewall who block CDO?

Or other reason that I don't know...

I had used the script on only four computers, all on win-XP

Have you try with WSH? Or VBscript?

For info, I use also Wscite ; but in French, with a config "house".

Trop cool ton script. Ca fais du bien de lire des postes venant de francophones.

Bienvenue a autoit et merci pour ta participation.

IE. You rock.

-Monkey

Edited by blademonkey

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Share this post


Link to post
Share on other sites

Bonsoir !

Si tu es en France, tu seras peut-être intéressé par les

Rencontres-Paradox-Ponx-2005

Dans lesquelles je vais présenter plusieurs utilitaires développés avec AutoIt, et utilisables sous Paradox, avec Python, ou en invite de commande.

Plus de renseignements ici :

Rencontres-Paradox-Ponx-2005

@-salutations

Michel Claveau

Share this post


Link to post
Share on other sites

Michel Claveau its a really really disrespectful to write on your own language!

This is an international forum!

Share this post


Link to post
Share on other sites

Michel Claveau its a really really disrespectful to write on your own language!

This is an international forum!

You little clown.

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

i just discovered a little problem using your script

if you just do your code in an empty script and run it, scite gives this msg:

got a clue why it doesn't work?

I got the same message. compiled it and ran as administrator with no luck. Could this be because I am in windows 7? I tried it on an xp comp, but I got the same error (maby it was because I was not admin on there)


0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Michel Claveau its a really really disrespectful to write on your own language!

This is an international forum!

Yes but the French always think French should be THE language for international discourse.

It's all there fault anyway, they helped the USA get independence and it has backfired on them because it's really the US that has made english the world language.Now the French have to speak english, how terrible for them.

Edited by automatedfaults

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