
Newbie Emailing text file into body of Email
Quote:
> I'm just learning about VBScript so please be gentle. I have written the
> following script:
> ' Emails text file quickly.
> Option Explicit
> Dim oFSO, oFile
> Dim strFilename, strData
> Dim emadd, emsub
> Dim WshShell, oExec
> Const ForReading = 1
> Const ForWriting = 2
> strFileName = "email.txt"
> ' Reads Email.txt for Body of Email message.
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> Set oFile = oFSO.OpenTextFile(strFileName, ForReading)
> strData = oFile.ReadAll
> oFile.Close
> emadd = InputBox("Type in email address")
> emsub = InputBox("Type in subject")
> Set WshShell = CreateObject("WScript.Shell")
> WshShell.Run "mailto:" & emadd & "?subject=" & emsub & "&body=" & strData
> The problem comes at the very end. The "mailto:" command can't have
any
> spaces in the command that is sent to the run method. You can get around
> that my enclosing quotes around two words or several words.
> My question is how would I do that for my variables. Right now if the
> Subject contains two words it opens a message window, but only the first
> subject word is in the subject line, and no message body. If the subject
is
> one word then it fail after the first word in the body.
> Is there a way I can work around this to use the mailto command. I
> would like to do it this way so I can add more addresses or add to the
body
> in the message window.
> Thank you for any help.
Maybe you should rethink what you're trying to do. The mailto command opens
their current email client with a new message with the stuff you've
specified, but you make them type in the email address and subject
beforehand anyway. Seeing as they'll have a chance to change those anyway
when they send a file, your script is kinda pointless. Maybe you should just
stick with the Send To menu or possibly drag the Mail Recipient icon from
the SentTo folder to the desktop so they can drag to it instead.