AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

AHKEmail
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
xXJa50nXx



Joined: 19 Oct 2006
Posts: 32
Location: mo

PostPosted: Thu Oct 26, 2006 9:58 pm    Post subject: AHKEmail Reply with quote

This is just an example of how to send a email with ahk using vbs.
Very simple but it works well.

Im sorry if this has been done before, i couldnt find anyhting on it.

~Jason

Code:

Gui, Add, Edit,vFROM x66 y27 w100 h20
Gui, Add, Edit,vTo x66 y57 w100 h20 ,
Gui, Add, Edit,vSmtp x66 y87 w100 h20
Gui, Add, Edit,vSubject x66 y117 w100 h20
Gui, Add, Edit,vBody x66 y147 w240 h100
Gui, Add, Text, x6 y27 w60 h20 R4 , From:
Gui, Add, Text, x6 y57 w60 h20 , To:
Gui, Add, Text, x6 y87 w60 h20 , SMTP:
Gui, Add, Text, x6 y117 w60 h20 , Subject:
Gui, Add, Text, x6 y147 w60 h20 , Body:
Gui, Add, button, x6 y210  , Send
Gui, Show, x207 y497 h270 w318, AHK Email
return

GuiClose:
ExitApp

ButtonSend:
Gui, Submit, NoHide
TEMPFILE = %TEMP%\EMAIL.vbs
IfExist, %TEMPFILE%
   FileDelete, %TEMPFILE%
FileAppend, set objmessage = createobject("cdo.message")`n objmessage.from = "%FROM%" `n objmessage.to = "%To%" `n objmessage.subject = "%Subject%" `n objmessage.textbody = "%Body%" `n objmessage.configuration.fields.item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 `n objmessage.configuration.fields.item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "%Smtp%" `n objmessage.configuration.fields.item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 `n  objmessage.configuration.fields.update `n objmessage.send ,%TEMPFILE%
RunWait, %TEMPFILE%
FileDelete, %TEMPFILE%
Return
Back to top
View user's profile Send private message Send e-mail
SoggyDog



Joined: 02 May 2006
Posts: 214
Location: Greeley, CO

PostPosted: Thu Oct 26, 2006 11:02 pm    Post subject: Reply with quote

We've tinkered with Blat.dll for email, but I've not seen attempts using VBS.

I'm getting an error when I try it, but I'm about to leave work and spend some time with the family. I'll look in to it later.

I think this may have some potential.

Look at you go... Two nice scripts in a row.
_________________

SoggyDog
Download AutoHotKey Wallpaper
Does 'Fuzzy Logic' tickle?
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
xXJa50nXx



Joined: 19 Oct 2006
Posts: 32
Location: mo

PostPosted: Fri Oct 27, 2006 12:47 am    Post subject: Reply with quote

It works well as long as you have the right smtp server.
Back to top
View user's profile Send private message Send e-mail
SoggyDog



Joined: 02 May 2006
Posts: 214
Location: Greeley, CO

PostPosted: Fri Oct 27, 2006 2:10 am    Post subject: Reply with quote

Here's the error I mentioned before.
Any ideas?...



Thanks-
_________________

SoggyDog
Download AutoHotKey Wallpaper
Does 'Fuzzy Logic' tickle?
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
xXJa50nXx



Joined: 19 Oct 2006
Posts: 32
Location: mo

PostPosted: Fri Oct 27, 2006 2:16 am    Post subject: Reply with quote

ok
i found the problem.
It doesnt like ti when you type more than one line in the body box.
Try just one line with no extra lines. Ill look into how to fix it.

Thanks,
Jason
Back to top
View user's profile Send private message Send e-mail
garry



Joined: 19 Apr 2005
Posts: 1030
Location: switzerland

PostPosted: Fri Oct 27, 2006 5:32 am    Post subject: Reply with quote

have an easy example here
http://www.autohotkey.com/forum/topic4526.html
do you know how to send an attachement ?
Back to top
View user's profile Send private message
slomz



Joined: 03 Sep 2006
Posts: 608
Location: Iowa, U.S.

PostPosted: Fri Oct 27, 2006 4:02 pm    Post subject: Reply with quote

I have a problem. Close to yours soggydog but at line 10.
_________________
Back to top
View user's profile Send private message AIM Address
maila
Guest





PostPosted: Mon Oct 30, 2006 11:27 am    Post subject: Reply with quote

Very good!
Sometime give me a error, sometime no. (???)
garry wrote:
have an easy example here
http://www.autohotkey.com/forum/topic4526.html
do you know how to send an attachement ?

Please, can you clarify?
Thanks. Very Happy
Back to top
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Mon Oct 30, 2006 12:15 pm    Post subject: Reply with quote

Found a French page on the topic (CDO), it seems sending attachments is possible. It gives useful links:
CDO 1.2
http://msdn.microsoft.com/library/en-us/cdo/html/_olemsg_overview_of_cdo.asp

CDO for Windows 2000:
http://msdn.microsoft.com/library/en-us/cdosys/html/_cdosys_about_cdo_for_windows_2000.asp

Note KB 171440
INFO: Where to Acquire the CDO Libraries (all versions)

They give an example of VBS script, which would be clearer than original code (which ignore continuation sections...):
Code:
With CreateObject("CDO.Message")
.From = "Me@MyISP.net"
.To = "HimOrHer@OtherISP.com"
.Subject = "Message Subject"
.TextBody = "Message Body." & VbNewLine & "Signature"
' ; OR (not both!)
.HTMLBody = "<html><body>Some ugly HTML message...</body></html>"
.AddAttachment("C:\OneFile.txt")
.AddAttachment("C:\AnotherFile.zip")
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
' ; Put a valid SMTP address here. Might not work if the SMTP server wants authentication...
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.example.com"
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Configuration.Fields.Update
On Error Resume Next
.Send
If Err Then MsgBox "Error when sending the message."
On Error GoTo 0
End With
It also shows that multi-line is OK, but you need to encode end-of-line chars... Otherwise, the VBS code will be invalid.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
SDG
Guest





PostPosted: Mon Oct 30, 2006 4:28 pm    Post subject: Reply with quote

So, for those of us that don't really get some of this scripting stuff, can somebody put the new VBS in to a script like the first one?
Back to top
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Mon Oct 30, 2006 5:05 pm    Post subject: Reply with quote

The following works for me.
It can be refined more, that's more a proof of concept than a substitute for Outlook Express...
Code:
Gui Add, Text, x8 y8 w100 h20, From:
Gui Add, Edit,vfromAddress x80 y7 w100 h20
Gui Add, Text, x8 y48 w100 h20, To:
Gui Add, Edit,vtoAddresses x80 y47 w200 h20
Gui Add, Text, x8 y88 w100 h20, Subject:
Gui Add, Edit,vsubjectLine x80 y87 w250 h20
Gui Add, Text, x8 y128 w100 h20, Body:
Gui Add, Edit,vbody x80 y127 w250 h100
Gui Add, Text, x8 y248 w100 h20, SMTP Server:
Gui Add, Edit,vsmtpServer x80 y247 w200 h20
Gui Add, button, x130 y280 w80 h25, Send
Gui Show, , AHK e-mail
Return

GuiClose:
ExitApp

ButtonSend:
Gui Submit, NoHide
emailScriptFile = %A_Temp%\$$e-mail$$.vbs
IfExist %emailScriptFile%
   FileDelete %emailScriptFile%
StringReplace body, body, `n, " & vbNewLine & ", All
FileAppend,
(
With CreateObject("CDO.Message")
.From = "%fromAddress%"
.To = "%toAddresses%"
.Subject = "%subjectLine%"
.TextBody = "%body%"
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "%smtpServer%"
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Configuration.Fields.Update
On Error Resume Next
.Send
If Err Then MsgBox "Error when sending the message."
On Error GoTo 0
End With
), %emailScriptFile%
RunWait %emailScriptFile%, , Hide
;~ Run Notepad.exe %emailScriptFile%
FileDelete %emailScriptFile%
Return

_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
garry



Joined: 19 Apr 2005
Posts: 1030
Location: switzerland

PostPosted: Mon Oct 30, 2006 6:56 pm    Post subject: Reply with quote

@ maila:
Code:
run,mailto:garry@freenet.us?subject=Greetings&Body=Hallo Garry`,`%0a`%0dHow are you ?`%0aNext Line...
this works but I don't know how to add an attachment
some links here, maybe not possible
http://www.faqs.org/rfcs/rfc2368.html
http://www.ianr.unl.edu/internet/mailto.html
http://www.codeproject.com/internet/SendTo.asp

@PhiLho:
get error with thunderbird
Back to top
View user's profile Send private message
SoggyDog



Joined: 02 May 2006
Posts: 214
Location: Greeley, CO

PostPosted: Mon Oct 30, 2006 7:02 pm    Post subject: Reply with quote

And would it be possible, then, to read your mail with VBS?
_________________

SoggyDog
Download AutoHotKey Wallpaper
Does 'Fuzzy Logic' tickle?
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
garry



Joined: 19 Apr 2005
Posts: 1030
Location: switzerland

PostPosted: Mon Oct 30, 2006 7:25 pm    Post subject: Reply with quote

Quote:
some links here, maybe not possible
... to add an attachment to:
run,mailto:garry@freenet.us?subject=Greetings&Body=Hallo Garry`,`%0a`%0dHow are you ?`%0aNext Line...
sorry, can't english, just a little bit
Back to top
View user's profile Send private message
SoggyDog



Joined: 02 May 2006
Posts: 214
Location: Greeley, CO

PostPosted: Mon Oct 30, 2006 7:30 pm    Post subject: Reply with quote

garry wrote:
...I don't know how to add an attachment...


I don't think you can add attachments with mailto:

Quoting one of the URLs you referenced;

Quote:

The MailTo command can do more than enter a single e-mail address in
the "Send To" field while activating your e-mail program.

It can also:

Feature ---> Syntax
=============
Address message to multiple recipients ---> , (comma separating e-mail addresses)
Add entry in the "Subject" field ---> ?subject=Subject Field Text
Add entry in the "Copy To" or "CC" field ---> ?&cc=id@internet.node
Add entry in the "Blind Copy To" or "BCC" field ---> ?&bcc=id@internet.node
Add entry in the "Body" field ---> ?&body=Your message here


_________________

SoggyDog
Download AutoHotKey Wallpaper
Does 'Fuzzy Logic' tickle?


Last edited by SoggyDog on Mon Oct 30, 2006 7:42 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group