 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
xXJa50nXx
Joined: 19 Oct 2006 Posts: 32 Location: mo
|
Posted: Wed Jul 18, 2007 8:29 pm Post subject: Send a attachment without any dll calls. |
|
|
This is a very simple example of how to send a attachment.
Just put the full file name in the attach variable.
| Code: |
attach= ;filename here.
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
StringReplace, body, body, `n,<br> , All
TEMPFILE = %TEMP%\EMAIL.vbs
IfExist, %TEMPFILE%
FileDelete, %TEMPFILE%
FileAppend, set objmessage = createobject("cdo.message")`n objmessage.from = "%FROM%" `n objMessage.AddAttachment "%Attach%"`n objmessage.to = "%To%" `n objmessage.subject = "%Subject%" `n objmessage.htmlbody = "%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
|
With this code you can send as many attachments as you want.
This code will send a directory.
| 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
StringReplace, body, body, `n,<br> , All
TEMPFILE = %TEMP%\EMAIL.vbs
IfExist, %TEMPFILE%
FileDelete, %TEMPFILE%
file= set objmessage = createobject("cdo.message")`n objmessage.from = "%FROM%" `n
FileSelectFolder,folder
Loop, %folder%\*, , 1 ; Recurse into subfolders.
{
file=%file%objMessage.AddAttachment "%A_LoopFileFullPath%"`n
}
file=%file%objmessage.to = "%To%" `n objmessage.subject = "%Subject%" `n objmessage.htmlbody = "%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
FileAppend, %file% ,%TEMPFILE%
RunWait, %TEMPFILE%
FileDelete, %TEMPFILE%
msgbox Sent
Return
|
|
|
| Back to top |
|
 |
Helpy Guest
|
Posted: Thu Jul 19, 2007 3:16 pm Post subject: |
|
|
| Note: with continuation sections, you can avoid putting `n everywhere, which is neither practical nor readable. |
|
| Back to top |
|
 |
xXja50nXx as a guest Guest
|
Posted: Thu Jul 19, 2007 6:57 pm Post subject: |
|
|
| Note: Thats not a continuing section, its a line that is wrapping. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Thu Jul 19, 2007 6:59 pm Post subject: |
|
|
then it should be made into a continuation section. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
xXja50nXx as a guest Guest
|
Posted: Thu Jul 19, 2007 7:28 pm Post subject: |
|
|
| Im not a vb programmer. lol. |
|
| Back to top |
|
 |
daonlyfreez
Joined: 16 Mar 2005 Posts: 745 Location: Berlin
|
Posted: Thu Jul 19, 2007 7:38 pm Post subject: |
|
|
Example
| Code: | FileAppend,
(LTrim ` Join`s
%file%objmessage.to = "%To%" `n
objmessage.subject = "%Subject%" `n
objmessage.htmlbody = "%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% |
_________________ (sorry, homesite offline atm) |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Thu Jul 19, 2007 7:45 pm Post subject: |
|
|
| Code: |
FileAppend,
(LTrim
%file%objmessage.to = "%To%"
objmessage.subject = "%Subject%"
objmessage.htmlbody = "%Body%"
objmessage.configuration.fields.item
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objmessage.configuration.fields.item
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "%Smtp%"
objmessage.configuration.fields.item
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objmessage.configuration.fields.update
objmessage.send
), %TEMPFILE%
|
why the ` option? it prevents `n from working. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
daonlyfreez
Joined: 16 Mar 2005 Posts: 745 Location: Berlin
|
Posted: Thu Jul 19, 2007 8:04 pm Post subject: |
|
|
I guess the VBS code needs those... dunno. _________________ (sorry, homesite offline atm) |
|
| Back to top |
|
 |
djeaton3162
Joined: 16 Sep 2006 Posts: 23
|
Posted: Thu Sep 20, 2007 7:15 pm Post subject: |
|
|
How do you go about specifying the SMTP server and its login and password?
D. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|