AutoHotkey Community

It is currently May 26th, 2012, 1:31 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: December 1st, 2008, 1:22 pm 
Offline

Joined: October 17th, 2008, 12:12 pm
Posts: 13
Location: KERALA
I want to send mail to a an account without showing the outlook mail interface.

I have searched in ahk. But i can't able to take that links, because that are restricted in my domain.

Pls Help me fast...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 1st, 2008, 3:15 pm 
Offline

Joined: July 18th, 2006, 12:18 pm
Posts: 403
use a dll like blat.
refer to: http://www.autohotkey.com/forum/viewtopic.php?t=10813

or you could write a php script to accept GET parameters, and execute it with URLDownloadToFile.

theres alot of ways.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 1st, 2008, 8:09 pm 
Offline

Joined: July 25th, 2006, 9:06 am
Posts: 51
This is how I write an email from a script to send a file.
It is Outlook specific, and from my view, dirty (in that using keys to make it work is just not right)
I spent a long time playing around with this as things like Attachement do not work from a script. Beyond my knowledge as to why, but it doesn't.
This is called from a gui and I haven't made it into a function

Code:
; This is Outlook specfic
; Code snippet by Peterm
;
Mail_File:
  ; Mail message out
  ShowConfirmationBox := 1

  ; If no file selected then return
  If MyListBox =
    {
      MsgBox No file selected
      SB_SetText("No file selected",1)
      Return
    }

  IfNotExist, %File_Link%
    {
      MsgBox %File_Link%`nFile does not Exist
      SB_SetText("File does not Exist",1)
      Return
    }

  SB_SetText("Mailing the file",1)
  Sleep, 50

  If ErrorLevel = Error
    {
      MsgBox Could not open specified file.  Perhaps it is does not Exist.
      SB_SetText("Couldn't open the selected file",1)
      Return
    }

  SB_SetText("Copying File to Clipboard",1)

  ; Load clipboard with file as this is quicker
  clipboard = %File_Link%
  ClipWait

  SB_SetText("Opening Outlook",1)

  var_subject = Drawing
  var_body = %File_Link%`%0A
  var_address = peter.meares@edwardsvacuum.com

  ; var_text = The shortcut to the file is `%0A`%0A
  var_sign_off = `%0A`%0ARegards`%0APeter

  ;Start the mail process
  RunWait mailto:%var_address%?body=%var_body%&subject=%var_subject%

  ; Add attachment to Outlook via key controls
  ; switch mouse and keys off
  BlockInput On

  Sleep 2000
  Send {ALT}
  Sleep 1000
  Send i
  Sleep 200
  Send f
  Sleep 1000
  Send ^v{Enter}
  Sleep 2000
  Send {End}{Down}

  BlockInput Off

  If (ShowConfirmationBox)
    {
      MsgBox 4,Email Confirmation, Send email?
      IfMsgBox Yes
        {
          Send ^{Enter}
          SB_SetText("File sent",1)
        }
      Else
          SB_SetText("File not sent",1)
    }

leave_routine:
Return


Peterm


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 2nd, 2008, 4:13 am 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
ok couple things
your either going to need to decide a mail client or learn about telnet
You can actually use telnet to send email from commandline
http://www.google.com/search?q=email+te ... 1I7SUNA_en
thats a bit of a learning curve for most but its totally doable
aside from telnet your going to need to designate a mail client.
outlook
browser based
blat
etc...
then your going to need to examin automation techniques for each
outlook you will want to learn about COM or vba and use ws4ahk by eric the turtle sky is the limit here but this has a steep learning curve
blat this will probably be the easiest to learn but it requires an additional download and program

browser based email

Now we are talking versitility here
you can use cURL
COM with IE
i Macros with firefox
or one of several winhttp functions found in the forums
COM is more viersitile but offers the most complex learning curve while cURL is probably the easiest but like the blat option will require an additional program

once you have decided a method your comfortable with then you can post more specific questions

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 2nd, 2008, 12:41 pm 
Offline

Joined: July 18th, 2006, 12:18 pm
Posts: 403
peterm wrote:
This is how I write an email from a script to send a file.
It is Outlook specific, and from my view, dirty (in that using keys to make it work is just not right)
I spent a long time playing around with this as things like Attachement do not work from a script. Beyond my knowledge as to why, but it doesn't.
This is called from a gui and I haven't made it into a function

Code:
; This is Outlook specfic
; Code snippet by Peterm
;
Mail_File:
  ; Mail message out
  ShowConfirmationBox := 1

  ; If no file selected then return
  If MyListBox =
    {
      MsgBox No file selected
      SB_SetText("No file selected",1)
      Return
    }

  IfNotExist, %File_Link%
    {
      MsgBox %File_Link%`nFile does not Exist
      SB_SetText("File does not Exist",1)
      Return
    }

  SB_SetText("Mailing the file",1)
  Sleep, 50

  If ErrorLevel = Error
    {
      MsgBox Could not open specified file.  Perhaps it is does not Exist.
      SB_SetText("Couldn't open the selected file",1)
      Return
    }

  SB_SetText("Copying File to Clipboard",1)

  ; Load clipboard with file as this is quicker
  clipboard = %File_Link%
  ClipWait

  SB_SetText("Opening Outlook",1)

  var_subject = Drawing
  var_body = %File_Link%`%0A
  var_address = peter.meares@edwardsvacuum.com

  ; var_text = The shortcut to the file is `%0A`%0A
  var_sign_off = `%0A`%0ARegards`%0APeter

  ;Start the mail process
  RunWait mailto:%var_address%?body=%var_body%&subject=%var_subject%

  ; Add attachment to Outlook via key controls
  ; switch mouse and keys off
  BlockInput On

  Sleep 2000
  Send {ALT}
  Sleep 1000
  Send i
  Sleep 200
  Send f
  Sleep 1000
  Send ^v{Enter}
  Sleep 2000
  Send {End}{Down}

  BlockInput Off

  If (ShowConfirmationBox)
    {
      MsgBox 4,Email Confirmation, Send email?
      IfMsgBox Yes
        {
          Send ^{Enter}
          SB_SetText("File sent",1)
        }
      Else
          SB_SetText("File not sent",1)
    }

leave_routine:
Return


Peterm


This is fine if the script is for personal use only then you can set things up accordingly.

This is no way effcient for distribution thou. Go with blat or telnet.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 16th, 2008, 1:05 am 
Offline

Joined: July 2nd, 2006, 9:04 pm
Posts: 25
I have to use a .JS file to get the job done.

In my AHK code I use:
Code:
Run %comspec% \c "Path to my JS script file" "email address of recipient" "subject line" "file path of attachment" "bodyofemail"


Every argument is handed off in quotes to ensure spaces are delt with appropriately.

just save this as something.js
Code:
/* Usage:
scriptname email@to.me "About something" "C:\test.txt" "I wanted to send this email to you about something. Please see the attachment."
 */
 var WshShell = WScript.CreateObject("WScript.Shell");
 var objArgs = WScript.Arguments
 if (objArgs.length != ""){
  for (i=0; i < objArgs.length; i++)
   {
      switch (i){
         case 1:
         var to = objArgs(i);
         break;
         case 2:
         var subject = objArgs(i);
         break;
         case 3:
         var attach = objArgs(i);
         break
         case 4:
         var body = objArgs(i);
         break
         default : WshShell.Popup("That is to many arguments!", //message to display
                0, //seconds to leave window up; 0 = forever
                "What are you thinking?", //title
                0+48); //icon + buttons   see: http://msdn.microsoft.com/en-us/library/x83z1d9f.aspx;
      }
   }
 
  var outlookApp = new ActiveXObject("Outlook.Application");
  var nameSpace = outlookApp.getNameSpace("MAPI");
  mailFolder = nameSpace.getDefaultFolder(6);
  mailItem = mailFolder.Items.add('IPM.Note.FormA');
  mailItem.Subject = subject;
  mailItem.To = to;
  mailItem.HTMLBody = body;
  mailItem.Attachments.Add(attach)
  mailItem.display (0);
  outlookNamespace.Logoff;
  }
else
{
  WshShell.Popup("There are no arguments!", 0, "DUDE!", 0+48);
  }


Something like that.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Newl, poserpro, SifJar and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group