Right now, every time I want to interact with a web element using vbscript & uft, I do this:
.WebButton("xpath:=//div[#id='controls']/button[text()='Load Game']").something
.WebButton("xpath:=//div[#id='controls']/button[text()='Load Game']").something_else
.WebButton("xpath:=//div[#id='controls']/button[text()='Load Game']").another_thing
Instead of this cumbersome way, can I do this with vbscript & uft:
Object x = .WebButton("xpath:=//div[#id='controls']/button[text()='Load Game']")
x.something
x.something_else
x.another_thing
Is this possible/easy in vbscript ? If not, then why ?
I accidentally got an answer here. The solution is not exactly what I was expecting, but it is close to what I need. I was using static programming. I should be using dynamic programming instead.
Dynamic descriptive programming
'Launch gmail
systemutil.Run "iexplore.exe","http:\\www.gmail.com"
'Descriptive object to identify Browser with a particular title
Set Dbrowser=description.Create
Dbrowser("micclass").value="Browser"
Dbrowser("title").value="Gmail: Email from Google"
'Descriptive object to identify Web page with a particular title
Set Dpage=description.Create
Dpage("micclass").value="Page"
Dpage("title").value="Gmail: Email from Google"
'Descriptive object to identify a particular Web Button
Set Dbutton=description.Create
Dbutton("micclass").value="WebButton"
Dbutton("name").value="Sign in"
'Descriptive object to identify Web Text Box
Set Dedit=description.Create
Dedit("micclass").value="WebEdit"
Dedit("name").value="Email"
'wait till browser loads
Browser(Dbrowser).Page(Dpage).Sync
' Enter Email id in Username Field
Browser(Dbrowser).Page(Dpage).WebEdit(Dedit).Set "qtpworld.com"
Dedit("name").value="Passwd"
'Enter password in Passowrd Field
Browser(Dbrowser).Page(Dpage).WebEdit(Dedit).Set "qtp"
'Cick on the Sign In Button
Browser(Dbrowser).Page(Dpage).WebButton(Dbutton).Click
Static descriptive programming:
'Username="qtpworld.com"
'Password="qtp"
'*****************************Login to gmail account using Static descriptive Programing ******************************
'Launch gmail
systemutil.Run "iexplore.exe","http:\\www.gmail.com"
'Assign object property value to a variable pwd
pwd="Passwd"
'Wait till browser loads
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").Sync
' Enter Email id in Username Field
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").WebEdit("name:=Email").Set "qtpworld.com"
'Enter password in Passowrd Field
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").WebEdit("name:=" & pwd).Set "qtp"
'Cick on the Sign In Button
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").WebButton("name:=Sign in").Click
Related
I have only limited understanding of Applescript but wanted to automate every time I recieve an email regarding an event to automatically create an event in calendar. I have set up a rule in Apple Mail to run an Applescript when the email comes from a specific sender.
What I have so far:
using terms from application "Mail"
on perform mail action with messages caughtMessages for rule 'placeholder rule'
repeat with caughtMessage in caughtMessages
try
set theContent to content of caughtMessage
set theSubject to subject of caughtMessage
on error errorString number errorNumber
display dialog errorString
end try
end repeat
set theLocation to "fixed location"
set theStart to ??? Retreive start date from email ???
set theEnd ??? Retreive end date from email ???
tell application "Calendar"
set theCalendar to "QRESERVE TRAININGS"
tell calendar (get theCalendar as text)
make new event with properties {summary:theSubject, start date:theStart, end date:theEnd, location:theLocation, description:theContent}
end tell
end tell
end perform mail action with messages
end using terms from
The date and time that I am trying to retrieve from the email is formatted as such:
Image of Date and Time formatting
I've got how to run the automation as part of a rule in mail and how to create the subsequent calendar event, but no clue how to extract the date and time of the event. Any help would be hugely appreciated!!
I've tried using grep but had no success with that...
The following piece of code is supposed to send a notification from my bot to me when a user is interacting with it. The message should contain the user name or better a link to directly chat with the user. How do I return the username inform of a clickable link to directly chat with the user. Or better how can I get a link to chatting with the user, whether he or she has a username or not.
I am using ruby programming language.
when '/yes'
bot.api.send_message(chat_id: 1233454991, text: " You have a new inquiry from #{message.from.username} ")
end
I just found a solution. Just adding an # in front of the literal string gives me the desired output
when '/yes'
bot.api.send_message(chat_id: 1233454991, text: " You have a new inquiry from ##{message.from.username} ")
end
I have written 9 routines in the last few weeks in Powershell for Domino, they all appear to do what I need except 1!
This is the RegisterNewUser method, which does everything except the Email address. If I setup a user via Domino Administrator, I get everything including the email address ie internal address that is 'bob patz/smallhome'.
If I use my code this uses the registration process but all I end up with is the domain part of the internal email address '#smallhome'.
Does anyone know how to correct this? I don't think powershell uses the #formula language in any form, so I assume i somehow need to find the right column in a document or database and append the fullname in there somehow.
Is there anyone out there who can help in anyway?
regards
Mark
<#TOP TIP: THIS MUST RUN UNDER POWERSHELL (X86), ELSE IT WILL NOT WORK!!
This Powershell Function was created in March 2020 by (myself) Mark Baker as 'a' just to see if I can de-mystify
some of the Domino Database stucture, after running short bits of code and using Get-Member on some parts
of it and looking at online code snippets and reading some of the online info from IBM I have come up with
the function below to Create a New Lotus Notes User.
#
Original Code: 31/03/2020 by MBaker
A lot of work testing and diagnosing the different settings and values EVENTUALLY lead me to getting this working,
as at 08/04/2020 I just need to work out the settings for setting the correct email address per person.
#
This is how to use this function:
New-DominoUserRegistration "hazell" "C:\Program Files\IBM\Lotus\Notes\Data\ids\people\dhazell.id" "CN=Dom-01/O=Smallhome"
"Daniel" "" "swindon" "Work" "comment" "mail\dhazell" " " "password" 176
"dhazell"
Main use of this function is to connect to an IBM Domino Server and Create a New lotus notes user.
>
Function New-DominoUserRegistration {
[cmdletbinding()]
param (
[parameter(Position=0,Mandatory=$true,ValueFromPipeline=$True)][string]$lastname,
[parameter(Position=1,Mandatory=$true,ValueFromPipeline=$True)][string]$Useridfile,
[parameter(Position=2,Mandatory=$true,ValueFromPipeline=$True)][string]$mailserver,
[parameter(Position=3,Mandatory=$true,ValueFromPipeline=$True)][string]$firstname,
[parameter(Position=4,Mandatory=$false,ValueFromPipeline=$True)][string]$middle,
[parameter(Position=5,Mandatory=$true,ValueFromPipeline=$True)][string]$certpw,
[parameter(Position=6,Mandatory=$true,ValueFromPipeline=$True)][string]$location,
[parameter(Position=7,Mandatory=$true,ValueFromPipeline=$True)][string]$comment,
[parameter(Position=8,Mandatory=$true,ValueFromPipeline=$True)][string]$maildbpath,
[parameter(Position=9,Mandatory=$true,ValueFromPipeline=$True)][string]$fwddomain,
[parameter(Position=10,Mandatory=$true,ValueFromPipeline=$True)][string]$userpw,
[parameter(Position=11,Mandatory=$true,ValueFromPipeline=$True)][int]$usertype,
[parameter(Position=12,Mandatory=$true,ValueFromPipeline=$True)][string]$ShortName
)
cls
# Create Lotus Notes Object
$DomSession = New-Object -ComObject Lotus.NotesSession
# Initialize Lotus Notes Object
# "It'll use your open notes session and authentication Details"
$DomSession.Initialize()
# Use Method from Objects returned in variable $domsession one of which is CreateAdministrationProcess which
# takes a Server as input
$adminProcess = $Domsession.CreateRegistration()
$expiration = (Get-Date).adddays(1095)
$adminprocess.certifieridfile="C:\Program Files (x86)\IBM\Lotus\Notes\Data\ids\cert.id"
$adminprocess.Expiration =$expiration
#$adminprocess.RegistrationLog ="C:\program files (x86)\IBM\lotus\notes\data\reglog.nsf"
#[int]$adminProcess.MinPasswordLength=5
$adminprocess.RegistrationServer="Dom-01/smallhome"
$adminprocess.UpdateAddressBook=$true
$adminProcess.GroupList="Test4"
#$adminProcess.CreateMailDb=$true
#[int]$adminProcess.MailQuotaSizeLimit="100"
#[int]$adminProcess.MailQuotaWarningThreshold="90"
$adminProcess.PolicyName="/Registration_Settings"
$adminProcess.ShortName=$ShortName
[int]$adminProcess.MailOwnerAccess=2
$adminProcess.MailACLManager="LocalDomainAdmins"
$adminProcess.MailInternetAddress="$ShortName"+"#smallhome.local"
$adminProcess.MailTemplateName="Mail85.ntf"
$Notesid=$adminprocess.RegisterNewUser($lastname,$Useridfile,$mailserver,$firstname,$middle,$certpw,$location,$comment,$maildbpath,$fwddomain,$userpw,$usertype)
}
New-DominoUserRegistration "archer" "C:\Program Files (x86)\IBM\Lotus\Notes\Data\ids\people\barcher.id" "CN=Dom-01/O=Smallhome" "basil" "" "swindon" "Work" "comment" "mail\barcher" " " "password" 176 "barcher"
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/2Wamq.png
I now have an answer for this, this came from someone else on another board: the line [parameter(Position=9,Mandatory=$true,ValueFromPipeline=$True)][string]$fwddomain,
Needed to have [AllowEmptyString()] inserted before [string]$fwddomain, and the input field was " " and needed to be "". It appears the $fwddomain has an impact on the internal email address name ie: 'bob patz/smallhome'.
I have tested this and it shows up in the people view and also I can now send emails to other users and ones self!
Problem solved.
Regards
Mark
I would like to send an email with applescript. This script will be used on a few computers and the email should be sent by a certain type of account containing "mynetwork.com" in the email address.
Is there a way to automatically select the computer email account containing "my network.com" ? Obviously the wildcard * is not working see code below
property faxboxEmail : {"fax#opilbox.com"}
property theNumber : ""
property theContent : ""
property theSender : "*#mynetwork.com"
tell application "Mail"
set newMessage to make new outgoing message with properties {visible:true, subject:theNumber, content:theContent, sender:theSender}
tell newMessage
make new to recipient with properties {address:faxboxEmail}
end tell
end tell
The sender address for accounts in Mac OS X Mail are stored in the sender addresses property in an account. So, technically what you want is something like get account whose email addresses ends with "#mynetwork.com". However, the email addresses property is a simple list, and AppleScript doesn’t have dynamic searches into lists like that.
However, the number of accounts on any personal computer should be fairly small, so looping through them shouldn’t be a problem.
property faxboxEmail : {"fax#opilbox.com"}
property theNumber : "Nine"
property theContent : "Hello, World"
set foundAddress to false
tell application "Mail"
repeat with potentialSender in accounts
tell potentialSender
repeat with potentialAddress in email addresses as list
if potentialAddress ends with "#mynetwork.com" then
set foundAddress to true
exit repeat
end if
end repeat
end tell
if foundAddress then
exit repeat
end if
end repeat
if foundAddress then
set senderName to full name of potentialSender
set senderAddress to senderName & " <" & potentialAddress & ">"
set newMessage to make new outgoing message with properties {visible:true, subject:theNumber, content:theContent, sender:senderAddress}
tell newMessage
make new to recipient with properties {address:faxboxEmail}
end tell
end if
end tell
You may also find it useful to look at the properties of each account, using something like:
tell application "Mail"
--or “account 1”, “account 3”, etc., up to the number of accounts
get properties of account 2
end tell
If you run that and then look in the results pane, you’ll see all of the properties, including the email addresses property. If your script isn’t doing what you expect it to do, post not just the script, but also the values of the property you’re looking at, in this case the email addresses property. You will probably want to use a test computer with fake example.com, example.org, and example.net email addresses, so as not to expose real email addresses to harvesters.
You also may find it easier to build your scripts from the ground up. For example, in this case, you would want to write a script that sends a hard-coded email from a hard-coded sender. Only once that aspect of the script is working, would you want to add the wrinkle about searching for a dynamic sender. This will simplify your programming process by making each task smaller, and will also make it more obvious where the code is going astray.
i am making NewsLetter using the wysiwyg Editor.. it allows me to upload the Image Path
and Image Path is stored in the Upload Directory..
Not When i retrieve that Image using it works in website..
the editor's value is stored in database
example
<br> hi
<img src="upload/acb.gif">
<br>
Hello
i am sending Email and the detail of this email is received from database
and this detail is sent to visitor
he is gettion all text value but not able to see Image
so suggest me what to do..?
If you are sending emails using CDOSYS.Message, you can easily send a complete web page with embedded images using the Message.CreateMHTMLBody(url) method.
Dim Message
Set Message = CreateObject("CDOSYS.Message")
Message.From = "from#email.org"
Message.To = "to#email.org"
Message.CreateMTHMLBody "http://yourserver.org/email.html"
Message.Send()
I recently cleaned up some code I had lying around to do this and slapped it online as a "Gist" on github; hope it still helps someone!
Sending embedded images with CDOSYS
This solution uses CDO (CDOSYS / CDO.Message), with "AddAttachment", and manually controlling the properties of the attachments to make them usable from within the email HTML and to avoid them appearing as separately-downloadable attachments in an email client.
The usage is very simple, just reference the images by a local path (on the computer the code is running on) in the HTML of the message, eg:
Some Image: <img src="<EMBEDDEDIMAGE:C:\test.jpeg>" />
The code will pick up the filename, add the file as an attachment to the message, and replace the relevant part of the message HTML with the internal reference to that attachment.
You would have to add site url to img source
<img src="http://www.sitename.com/upload/acb.gif"> as the user is not accessing your site from his mailbox.
For this you can set "http://www.sitename.com/" as a key in web.config and use in your mails.
This will resolve your problem for sure. Happy coding !!!!!!!!!!!!!
You would use AddRelatedBodyPart:
Embed Usage
Create Array and Pass it in "SendMail" Function as Parameter
Use in Email Body e.g.
Dim arrRelatedBodyPart(1)
arrRelatedBodyPart(0) = Server.MapPath(".") & "/images/barcode/bar_blk.gif"
arrRelatedBodyPart(1) = Server.MapPath(".") & "/images/barcode/bar_wht.gif"
Example
For i = 0 To UBound(arrRelatedBodyPart)
Dim strPathAndFileName: strPathAndFileName = arrRelatedBodyPart(i)
Dim strFileName: strFileName = GetFileName(arrRelatedBodyPart(i), "/")
'.AddRelatedBodyPart strPathAndFileName, strFileName, cdoRefTypeId
Set objCDOBodyPart = .AddRelatedBodyPart(strPathAndFileName, strFileName, 1)
objCDOBodyPart.Fields.Item("urn:schemas:mailheader:Content-ID") = "<" & strFileName & ">"
objCDOBodyPart.Fields.Update
Next
What are you using to send the email, I have had success in the past using AspEmail: http://www.aspemail.com/
It explains how to send embedded images here: http://www.aspemail.com/manual_04.html
However you will have to get it installed on your server, if you are using Shared hosting this might be a problem, if you are running your own server pretty easy!