What does "initial form" mean in "Received:" header definition of RFC822? - email

As follows, RFC822 refers "Received:" header's "for" parameter as "initial form".
What does "initial form" mean? The word "initial form" is too generic.
received = "Received" ":" ; one per relay
["from" domain] ; sending host
["by" domain] ; receiving host
["via" atom] ; physical path
*("with" atom) ; link/mail protocol
["id" msg-id] ; receiver msg id
["for" addr-spec] ; initial form
";" date-time ; time received

AFAIK "for" part of Received: header (optionally) provides track of recipient address (at SMTP session level).

Related

VB script for send mail adding multiple variable recipients

I am relatively new to writing VB scripts. Essentially, I need to get a functioning VB script to send an email to multiple recipients which vary each email. I need it to have Subject Line, Email Body, Attachment and flexibility to add multiple recipients in the TO, CC and BCC fields without adding individual lines of Add.Recipient for each email address in the TO field. Does anyone have any suggestions or know of any resources to find this information?
I have looked myself and coming up somewhat blank on it.  I have the arguments set in a seperate.txt file. These will vary constantly. I am trying to do this as quickly but efficiently as possible.
I also have not had much luck with the Add.CC command so I took it out for this example...Below is what I currently have written out,
Set args = WScript.Arguments
arg1 = args.Item(0)
arg2 = args.Item(1)
arg3 = args.Item(2)
ToAddress = ""&arg1&""
CCAddress = ""&arg2&""
MessageSubject = "Your Order"
MessageBody = "Please find your Order Attached"
MessageAttachment = ""&arg3&""
Set ol = WScript.CreateObject("Outlook.Application")
Set ns = ol.getNamespace("MAPI")
Set newMail = ol.CreateItem(olMailItem)
newMail.Subject = MessageSubject
newMail.Body = MessageBody & vbCrLf & MyTime
newMail.RecipIents.Add(ToAddress)
newMail.Attachments.Add(MessageAttachment)
newMail.Send
I have the arguments written out as:
cscript //nologo test1.vbs email1#email.com email2#email.com y:\folder\test.txt
'Get email addresses, the -2 ignores the attachment
For x = 0 to WScript.Arguments.Count - 2
Msgbox Wscript.Arguments(x) & "Count " & x
Next
Msgbox Wscript.Arguments(wscript.arguments.count - 1) & " Attachment"
In programming we mostly use procedural steps, as you do. However very frequently we need to do loops. Because we wanted all but the last and then the last I used a For x = loop. For Each loops are usually better and cleaner code.
This prints out all arguments
For each Ag in WScript.Arguments
Msgbox Ag
Next

Numbers | Email | Applescript

I would like to create a numbers spreadsheet. In that spreadsheet I want to have COL A Email Col B City Name COL C Other City Name and so on. I will manually enter that data in.
What I would like to do next is have applescript go through line by line in the numbers spreadsheet and send an email to each person in the column. I would like to use the other variables in the subject or body of the email.
Any help would be appreciated! I am a novice at best programmer. I know a small bit of python but am new to applescript.
Pseudo code (maybe?)
tell numbers to open spreadsheet
repeat for each line of spreadsheet
tell mail to create email
for address COL A
for subject "Hello (COL B) I need the following Information (COL C)
for email Body "Blah Blah Blah (Col D) blah blah."
send email
end repeat
Email Function
on email(a, b, c, d)
set recipientName to a
set recipientAddress to b
set theSubject to c & " --> " & d & "Shipment"
set theContent to a & ", if you would like assistance with your shipment moving from " & c & " to " & d & " , or any other shipment you may have, please let me know. We have drivers available in your Area of Operations ready for pick up."
tell application "Mail"
##Create the message
set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
##Set a recipient
tell theMessage
make new to recipient with properties {name:recipientName, address:recipientAddress}
##Send the Message
send
end tell
end tell
end email
my email(COL A, COL B, COL C, COL D)
This is what I hacked together! I'm a newbie so be gentle. Improvements and critiques are greatly appreciated!
on email(emails, names, origin, destination)
set recipientName to names
set recipientAddress to emails
set theSubject to "c" & " --> " & "d" & "Shipment"
set theContent to names & ", if you would like assistance with your shipment moving from " & "c" & " to " & "d" & " , or any other shipment you may have, please let me know. We have drivers available in your Area of Operations ready for pick up."
tell application "Mail"
##Create the message
set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
##Set a recipient
tell theMessage
make new to recipient with properties {name:recipientName, address:recipientAddress}
##Send the Message
send
end tell
end tell
end email
on recipientNames()
set y to 1 as string
tell application "Numbers"
activate
open alias "Macintosh HD:Users:TYPKRFT:Desktop:Form.numbers"
tell table 1 of sheet 1 of document 1
set myNames to {}
repeat with i from 1 to the count of rows
set x to "B" & y
set myNames to myNames & the value of the cell x
set y to y as integer
set y to y + 1
set y to y as string
end repeat
end tell
end tell
set itemsToDelete to {"missing value", "Name", missing value, "stop"}
set cleanNames to {}
repeat with i from 1 to count myNames
if {myNames's item i} is not in itemsToDelete then set cleanNames's end to myNames's item i
end repeat
return cleanNames
end recipientNames
on emailAddress()
set y to 1 as string
tell application "Numbers"
activate
open alias "Macintosh HD:Users:TYPKRFT:Desktop:Form.numbers"
tell table 1 of sheet 1 of document 1
set myEmails to {}
repeat with i from 1 to the count of rows
set x to "C" & y
set myEmails to myEmails & the value of the cell x
set y to y as integer
set y to y + 1
set y to y as string
end repeat
end tell
end tell
set itemsToDelete to {"missing value", "Email", missing value, "stop"}
set cleanEmails to {}
repeat with i from 1 to count myEmails
if {myEmails's item i} is not in itemsToDelete then set cleanEmails's end to myEmails's item i
end repeat
return cleanEmails
end emailAddress
set a to emailAddress()
set b to my recipientNames()
set reps to count of a
set x to 1
repeat reps times
set emails to item x of a
set names to item x of b
my email(emails, names)
set x to x + 1
end repeat

Using VBS to call text file to populate to field in email

I am creating a script to be placed on servers to run without user interaction that will send an email when certain criteria are met. I have the criteria script running, but I want to make the script easy to deploy and modify for each individual server.
I am trying to make the script make a call to a text file to populate the TO field in the email. The text file will have the email addresses placed one per line (I was putting a semicolon on the end of the addresses since I know multiple TO addresses are separated by semicolons)
I have tried a number of different variations on calling the script and I either get an error on the To line, or it makes it through the script and I get an error that no recipients were defined. Here is the script below:
`Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFileEmailAddresses = objFSO.OpenTextFile("EmailAddresses.txt", 1)
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set wshShell = WScript.CreateObject("WScript.Shell")
strComputerName = wshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
ServicesArray = Split (objFileEmailAddresses.ReadAll, vbNewLine)
For Each strService In ServicesArray
objDictionary.Add strService, strService
Next
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "email#server.com"
objEmail.To = objFileEmailAddresses
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp address"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Fields.Item("urn:schemas:mailheader:X-MSMail-Priority") = "High"
objEmail.Fields.Item("urn:schemas:mailheader:X-Priority") = 2
objEmail.Fields.Item("urn:schemas:httpmail:importance") = 2
objEmail.Fields.Update
objEmail.Subject = "Primary Server " & Ucase(strComputerName) & " is Rebooting Now"
objEmail.TextBody ="The primary server " & Ucase(strComputerName) & " is scheduled to reboot at this time. The server will be offline in less than one minute. .... "
objEmail.Send
objFileEmailAddresses.Close()`
The To field of your objEmail object should be a string containing one or more e-mail addresses. You're assigning a TextStream object (objFileEmailAddresses) to it.
You said your e-mail addresses already end with a semicolon? Try this instead:
' Open the text file containing all of the e-mail addresses...
Set objFileEmailAddresses = objFSO.OpenTextFile("EmailAddresses.txt", 1)
' Read the entire file. Replace newlines with nothing to get a single
' string of semicolon-separated e-mail addresses...
strAddresses = Replace(objFileEmailAddresses.ReadAll, vbCrLf, "")
' Assign the string to the e-mail object...
objEmail.To = strAddresses
You can get rid of the Dictionary object. Unless you're afraid you may have the same e-mail addresses listed more than once, in which case we may need to use one.

How to capture a WebElement value using QTP and put that value in the body of an e-mail in the middle of a sentence

I found a similar question that asks how to get a value of a WebElement and put it in an excel file and then e-mail the excel file, but how do I put that value of a WEbElement in the body of an e-mail in the middle of a sentence and NOT in an excel file?
For example, I want to capture a WebElement that tells me how many coke points I have and then I want to e-mail myself that value. Something like: "You have 500 Coke Points now".
This is what I have, but i'm getting a syntax error:
Dim ResultsFile
Set objOutlook=CreateObject("Outlook.Application")
Set objOutlookMsg=objOutlook.CreateItem(olMailItem)
objOutlookMsg.To="email#email.com"
ResultsFile="C:\Documents and Settings\Administrator\My Documents\CkeZeroPoints.xlsx"
objOutlookMsg.Subject="Coke Zero points"
objOutlookMsg.Body="You now have" &Browser("Sweepstakes.*").Page("Sweepstakes.*").WebElement("htmlID:=glPointsText").GetRoProperty("innertext") "Coke Zero points."
objOutlookMsg.Attachments.Add(ResultsFile)
objOutlookMsg.Display
objOutlookMsg.Send
Set objOutlookMsg=Nothing
Set objOutlook=Nothing
The syntax error starts on line 7.
Thank you in advance.
You forgot an ampersand (&):
Dim ResultsFile, innerText
Set objOutlook=CreateObject("Outlook.Application")
Set objOutlookMsg=objOutlook.CreateItem(olMailItem)
' Better to separate tasks so you can trap errors earlier
innerText = Browser("Sweepstakes.*").Page("Sweepstakes.*").WebElement("htmlID:=glPointsText").GetRoProperty("innertext")
ResultsFile = "C:\Documents and Settings\Administrator\My Documents\CkeZeroPoints.xlsx"
' email handling here, you can refactor this in a separate method
objOutlookMsg.To ="email#email.com"
objOutlookMsg.Subject = "Coke Zero points"
objOutlookMsg.Body = "You now have " & innerText & " Coke Zero points." ' <-- ampersand added on this line.
objOutlookMsg.Attachments.Add ResultsFile ' <-- parenthesis removed, only us parenthesis if
' you are calling a (returning) function
objOutlookMsg.Display
objOutlookMsg.Send
Set objOutlookMsg = Nothing
Set objOutlook = Nothing

Applescript for bulk email

Please can you check this script? I can not get it to work - I would like to use this to send the same e-mail to different addresses but with a personalised greeting.
— Script requires two files placed in the same folder as the script.
— “Email Addresses.txt" should contain email addresses separated by a carriage return.
— “Email Message.txt" should contain the Subject on the first line then the message body below (seperated by a carriage return).
— Get path to script where the support files should be stored.
set myPath to (path to me) as text
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set textChunks to text items of myPath
if last item of textChunks is "" then set textChunks to _chopLast(tectChunks)
set myFolderPath to _chopLast(textChunks) as text
set AppleScript's text item delimiters to oldDelims
log myPath
log myFolderPath
tell application "Finder"
-- Get the list of recipients
set recFile to (myFolderPath & ":Email Addresses.txt")
set recList to ""
set recFileID to (open for access (recFile as alias))
-- Extract text from the file
try
set fileLength to (get eof recFileID)
set recList to (read file recFile from 1 to (fileLength))
on error error_message number error_number
display alert "Error number: " & (error_number as string) & return ¬
& ("Message: ") & error_message
close access recFileID
end try
log recList
-- Get the email subject and body
set msgFile to (myFolderPath & ":Email Message.txt")
set msgFileID to (open for access (msgFile as alias))
-- Extract text from the file
try
set fileLength to (get eof msgFileID)
set emailBody to (read file msgFile from 1 to (fileLength))
on error error_message number error_number
display alert "Error number: " & (error_number as string) & return ¬
& ("Message: ") & error_message
close access msgFileID
end try
log emailBody
-- Seperate Subject from Body
set emailSubject to the first paragraph of emailBody
log emailSubject
set emailMsg to paragraphs 2 thru (count of paragraphs in emailBody) of emailBody
log emailMsg
set recListList to paragraphs in recList
-- Loop for each address.
repeat with eachAddress in (recListList)
set txtURL to ("mailto:" & eachAddress & "?subject=" & emailSubject & "&body=" & emailMsg as string)
open location txtURL
tell application "Mail"
activate
-- Uncomment the following line if you want to automatically send messages
-- send newMessage
end tell
end repeat
end tell
on _chopLast(theList)
return reverse of (rest of (reverse of theList))
end _chopLast
set addresses to "aa#example.com
bb#example.com"
set title to "title"
set body to "body"
--set body to read "/Users/username/Documents/body.txt" as «class utf8»
repeat with a in paragraphs of addresses
tell application "Mail"
activate
tell (make new outgoing message)
set visible to true
make new recipient at end of to recipients with properties {address:a}
set subject to title
set content to body
--send
end tell
end tell
end repeat