Add hyperlinked image to email signature using vbscript, using str string - vbscript

I realize this has been answered numerous times in the past, but I'm just having an issue with the final step of my hyperlinked icon in an email signature
I am adding my image and hyperlinking using the code below which works great, but I need to substitute the actual URL with an attribute from AD. I currently use strLinkedin = objUser.homePhone (I use home.Phone which is where I put the user's personal linkedin URL) and this works fine when I want to use strLinked, but I cannot seem to use it in the code below as the URL.
CODE - for images with a fixed URL (this works fine):
set objShape = objSelection.InlineShapes.AddPicture("\\path\share\4.png")
objSelection.Hyperlinks.Add objShape, "https://twitter.com/example";
Need to have it similar to (this doesn't work obviously, it just makes the link the show strLinkedIn):
set objShape = objSelection.InlineShapes.AddPicture(" \\path\share\4.png")
objSelection.Hyperlinks.Add objShape, "strLinkedIn"
Using the code just above, the output shows the text strLinkedin rather than the result of strLinkedin = objUser.homePhone.
If someone could please possibly help me with the final 'tweak' that would really be appreciated.

Fixed, code is:
strLinkedin = objUser.homePhone
set objShape = objSelection.InlineShapes.AddPicture("\path\share\4.png")
objSelection.Hyperlinks.Add objShape, strLinkedIn
Simply, no "".

Related

Google sheets IMPORTXML fails for ASX data

I am trying to extract the "Forward Dividend & Yield" value from https://finance.yahoo.com/ for multiple companies in different markets, into Google Sheets.
This is successful:
=IMPORTXML("https://finance.yahoo.com/quote/WBS", "//*[#id='quote-summary']/div[2]/table/tbody/tr[6]/td[2]")
But this fails with #N/A:
=IMPORTXML("https://finance.yahoo.com/quote/CBA.AX", "//*[#id='quote-summary']/div[2]/table/tbody/tr[6]/td[2]")
I cannot work out what needs to be different for ASX ticker codes, why does CBA.AX cause a problem?
Huge thanks for any help
When I tested the formula of =IMPORTXML("https://finance.yahoo.com/quote/CBA.AX", "//*"), an error of Error Resource at url not found. occurred. I thought that this might be the reason of your issue.
But, fortunately, when I try to retrieve the HTML from the same URL using Google Apps Script, the HTML could be retrieved. So, in this answer, I would like to propose to retrieve the value using the custom function created by Google Apps Script. The sample script is as follows.
Sample script:
Please copy and paste the following script to the script editor of Google Spreadsheet and save it. And, please put a formula of =SAMPLE("https://finance.yahoo.com/quote/CBA.AX") to a cell. By this, the value is retrieved.
function SAMPLE(url) {
const res = UrlFetchApp.fetch(url).getContentText().match(/DIVIDEND_AND_YIELD-value.+?>(.+?)</);
return res && res.length > 1 ? res[1] : "No value";
}
Result:
When above script is used, the following result is obtained.
Note:
When this script is used, you can also use =SAMPLE("https://finance.yahoo.com/quote/WBS").
In this case, when the HTML structure of the URL is changed, this script might not be able to be used. I think that this situation is the same with IMPORTXML and the xpath. So please be careful this.
References:
Custom Functions in Google Sheets
Class UrlFetchApp
An other solution is to decode the json contained in the source of the web page. Of course you can't use importxml since the web page is built on your side by javascript and not on server's side. You can access data by this way and get a lot of informations
var source = UrlFetchApp.fetch(url).getContentText()
var jsonString = source.match(/(?<=root.App.main = ).*(?=}}}})/g) + '}}}}'
i.e. for what you are looking for you can use
function trailingAnnualDividendRate(){
var url='https://finance.yahoo.com/quote/CBA.AX'
var source = UrlFetchApp.fetch(url).getContentText()
var jsonString = source.match(/(?<=root.App.main = ).*(?=}}}})/g) + '}}}}'
var data = JSON.parse(jsonString)
var dividendRate = data.context.dispatcher.stores.QuoteSummaryStore.summaryDetail.trailingAnnualDividendRate.raw
Logger.log(dividendRate)
}

How to activate randomized filenames in powermail

i have a form where user could upload files. There are 3 files they could upload and each of them need to have an unique name. So even the person upload the same file everytime i neet different names for it in the email, i get from the form.
So i try to use randomizeFileName.
https://github.com/einpraegsam/powermail/blob/develop/Configuration/TypoScript/Main/setup.txt#L538
Cause i dont have the randomizeFilename in my constants.txt it try to enter it in my setup.txt with a real value.
# File upload settings
file {
folder = {$plugin.tx_powermail.settings.misc.uploadFolder}
size = {$plugin.tx_powermail.settings.misc.uploadSize}
extension = {$plugin.tx_powermail.settings.misc.uploadFileExtensions}
randomizeFileName = 1
}
But sadly that dont work. The file issues-1.pdf still has the same name (+ a suffix cause i tried it a lot time )
I hope someone can help me. Thank you very much!
Based on the setup file included in the extension, the correct syntax for Powermail 7.x would be:
plugin.tx_powermail.settings.misc.randomizeFileName = 1
randomizeFileName = 1 is the default value in Powermail 7.x!
You have to set this over Typoscript Constant, not in Typoscript Setup:
In Typoscript Setup this may work. (Not Tested)
plugin.tx_powermail.settings.Pi2.misc.file.randomizeFileName = 1
Read the source code to see more:
https://github.com/einpraegsam/powermail/blob/develop/Configuration/TypoScript/Powermail_Frontend/setup.txt
Or the documentation: https://docs.typo3.org/typo3cms/extensions/powermail/stable/ForAdministrators/BestPractice/MainTypoScript/Index.html

QTP recognising a JavaEdit object but not able to set a value when running the script

I have written a simple script to log into a Java app where it fills in username and password, and then clicks on the "Connect" button".
Set UVC = JavaDialog("UVC")
wait(20)
If UVC.Exist Then
UVC.JavaEdit("JTextField").Set "admin"
wait(2)
UVC.JavaEdit("PSW").SetSecure "5256833195fsdqsdsqd447e4beefsdsdqd"
wait(5)
UVC.JavaButton("Connect").Click
Else
print "Console is not present"
End If
It's strange as QTP is identifying my password field properly. When running the following code I get a value back as expected:
MsgBox Main.JavaEdit("password").GetROProperty("attached_text")
I have also tried to set the password without encrypting it but it's also not working.
PS: the same script was working before and has since stopped working for an unknown reason!!!
Thanks in advance.
Replace
UVC.JavaEdit("PSW").SetSecure "5256833195fsdqsdsqd447e4beefsdsdqd"
with
UVC.JavaEdit("PSW").Click 1,1
UVC.JavaEdit("PSW").SetSecure "5256833195fsdqsdsqd447e4beefsdsdqd"
and it will work even with replay mode = "event". If you want to beautify this, you can use a click in the middle of the field, like in:
With UVC.JavaEdit("PSW")
.Click .GetROProperty ("width")\2, .GetROProperty ("height")\2
.SetSecure "5256833195fsdqsdsqd447e4beefsdsdqd"
End With
It seems that most Java password fields must first be focussed to be SetSecure-able.
Just to be sure.. check whether the field is enabled by testing .getroproperty("editable").
Use any of these methods to set text in Java Edit field.
You could use JavaEdit("PSW").Object.Settext method - this uses the JTextField in JavaSwing object properties
You could use setfocus method before entering the string in the field
Get the position of the test field
x = JavaEdit("PSW").Getroproperty("abs_x")
y = JavaEdit("PSW").Getroproperty("abs_y")
Set DRP = CreateObject("Mercury.DeviceReplay")
DRP.MouseClick x,y,"0"
DRP.SendString "the string"
You could also use JavaEdit's type object
Any of these methods should work for you. If not tough luck.. :)
Thanks for your answers but none of your suggestions worked, I have ended up using a basic turnaround :
UVC.JavaEdit("JTextField").Set"admin"
UVC.JavaEdit("PSW").Click 1,1
UVC.JavaEdit("PSW").SetSecure"52581237d889935df36ae78587773a641f40"
UVC.JavaButton("Connect").Click
wait (5)
While JavaDialog("Login Error").Exist
JavaDialog("Login Error").JavaButton("Ok").click
UVC.JavaEdit("PSW").RefreshObject
UVC.JavaEdit("PSW").SetSecure"52581237d889935df36ae78587773a641f40"
UVC.JavaButton("Connect").Click
Wend
I really don't get it how could the same function work sometimes and sometimes not!!

ms access linked image relitive path

I have an Image object.
I have the Picture type set to linked, so I can change the picture if I want.
I have the Picture property set to the picture name.
I would think that access would use relitive addressing and simple looking in the current directory for the image. But it does not and I get an error telling me it cannot find the picture.
Anyone have a solution? (Other than setting the Picture type to embedded or using the full file address?)
Thanks!
Update:
Tried this:
Private Sub Form_Load()
Dim file As String
file = CurrentDb().Name
file = Replace(file, ".mdb", ".bmp")
Me.Image46.Picture = file
End Sub
It works, except I still get the error message. I click O.K. and it works. Just need the error message to go away.
SOLUTION: Use the above code (or the code posted in the answer below) and then set the 'picture type' to "embedded" and then delete the 'picture' field so that it says "(none)".
Save and run.
It should work.
THANKS!
You could set the property on the forms OnLoad event like this
Me.imgMy_image.picture=getDBPath & “mypicture.bmp”
Here is the getDBPath function
Public Function GetDBPath() As String
Dim strFullPath As String
Dim I As Integer
strFullPath = CurrentDb().Name
For I = Len(strFullPath) To 1 Step -1
If Mid(strFullPath, I, 1) = "\" Then
GetDBPath = Left(strFullPath, I)
Exit For
End If
Next
End Function
Before anyone comments yes I know in access 2000 and above you can use currentproject.path but I’m stuck in the land that time forgot so need that custom function, it still works with later versions of access
Current folder depends of the way you open database in Access. At least, if you open it thru "File-Open", current folder changes to the folder of MDB file. But if you open via double-clicking MDB in explorer, it does not.

Send Email Using Classic ASP with an Embeded Image

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!

Resources