I am writing VBA code in Outlook 2007 to extract email address from emails.
I am able to read the body as a whole through a variable
How do I extract email address from the variable?
One method is described here.
sString = "my1#email.com xxx my2#email.com yyy my3#email.com"
asString = Split(sString, " ")
For i = 0 To UBound(asString)
If asString(i) Like "*#*.*" Then
sEmail = sEmail & "," & asString(i)
End If
Next
MsgBox Mid(sEmail, 2)
Why the body? Have you looked at the MailItem.Recipients collection (Recipient.Address) and the MailItem.SenderEmailAddress property?
Related
I'm really not very familiar with ASP, but the site I'm managing is spitting that error out to me. Here is the full code from the site:
Microsoft VBScript runtime error '800a0009'
Subscript out of range: '[number: 1]'
/shopping_sub.asp, line 715.
Here is the code from 697-728:
'Response.write strPass & "<p>"
'Response.write "Response: " & strResp
'Response.end
If strResp="ERROR" then
RESULT_num_shipping_options = -1
Session("ShipErrMsg")="To continue your order, please contact customer service regarding your contact information. Thank you."
Else
RESULT_num_shipping_options=1
vResp=Split(strResp,":")
Dim RESULT_shipping_description_array(4)
Dim RESULT_shipping_amount_array(4)
For I = 0 to UBound(vResp)
vResp2=Split(vResp(I),"|")
RESULT_shipping_description_array(I)=vResp2(0)
RESULT_shipping_amount_array(I)=vResp2(1)
Next
End If
Else
RESULT_num_shipping_options = -1
cShipping=0
End If
End If
'Response.write "Weight: " & siWeight & "<br/>"
'Response.write "Zip: " & receiverpostalcode & "<br/>"
'Response.write "Country: " & receivercountrycode & "<br/>"
It appears to start functioning after 7 items have been added to the cart, but anything less than that returns errors.
This doesn't happen with all products, so any idea?
Have you used a debugger to determine the value of vResp and the array length of vResp2?
My guess is that the response is not what you expected. If you can't force the api to always have the correct response, then you'll want to protect against it by checking the length of the split response before trying to access the value.
Another problem I see that is unrelated, is that if the UBound(vResp)_ > 4, then you'll get a similar error
This is a very peculiar issue. I have a 2012 Server running IIS 8 with support for classic ASP installed. I am building a comma separated string from a form. I then am retrieving this string from a table and want to split on the commas.
First, when I build the string and submit it to the DB (SQL Express 2014), something is adding a space after each comma even though there is no space in the code.
Second, when I return the string and attempt to split on the comma, it doesn't do anything; the ubound method returns -1... For testing purposes, I hand built an array and this has the same behavior.
Code that builds the csv string:
If fieldName = "txt_EnvironmentType" then
strTempEnvCSV = strTempEnvCSV & fieldValue & ","
End If
Test code for split:
txtEnvironmentType = "This,Is,A,Test,String"
If txtEnvironmentType <> "" then
response.write(txtEnvironmentType)
array = split(txtEnvironmentType,",")
l = ubound(array)
response.write("<br>array is " & l & " long")
For i = LBound(array) to UBound(array)
response.write("<br>" & array(i))
Next
End If
The Above test code returns the following to the browser:
This,Is,A,Test,String
array is -1 long
Am I missing something?
Thanks!
For the mysterious spaces, add a TRIM() to make sure you aren't starting with spaces:
If fieldName = "txt_EnvironmentType" then
strTempEnvCSV = strTempEnvCSV & TRIM(fieldValue) & ","
End If
This ran (for your second issue) for me - the only change I made was to dim the array variable and name it something other than "array"
<%
dim arrMine
txtEnvironmentType = "This,Is,A,Test,String"
If txtEnvironmentType <> "" then
response.write(txtEnvironmentType)
arrMine = split(txtEnvironmentType,",")
l = ubound(arrMine)
response.write("<br>arrMine is " & l & " long")
For i = LBound(arrMine) to UBound(arrMine)
response.write("<br>" & arrMine(i))
Next
End If
%>
How i can read this xml file
<Subs>
<Sub Report="BusinessSummarySubs" EMails="lalla#yahoo.com; haha#yahoo.com">
<Sub Report="PlayerSubs" EMails="hehe#hotmail.com">
</Subs>
and replace #VARIABLE in BusinesSummarySubs.txt with EMails value in
Here is the content(part of the content) from BusinessSumarySubs.txt
CType(extensionParams(0),ParameterValue).Name = "TO"
CType(extensionParams(0),ParameterValue).Label = ""
CType(extensionParams(0),ParameterValue).Value = "#VARIABLE"
If you look here, you'll see how to search for and to access attributes. Follow the link chain to 'the same for text' and do a mental diff, if you want to get a skeleton for a minimal XML processing script to use for your next task.
Single placeholder substitution in VBScript is easy: just use Replace:
>> attr = "lalla#yahoo.com; haha#yahoo.com"
>> content = "... .Value = ""#VARIABLE"" ..."
>> ph = "#VARIABLE"
>> WScript.Echo Replace(content, ph, attr)
>>
... .Value = "lalla#yahoo.com; haha#yahoo.com" ...
>>
Something like this i suposed
set xmlDoc=CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("note.xml")
for each Emails in xmlDoc.documentElement.childNodes
document.write(Emails .nodename)
document.write(": ")
document.write(Emails .text)
next
I am working with windows application.
I have a datagrid in vb.net. Its first column is a checkbox. I want to know which checkboxes are checked and which are not.
My code is :
Dim dr As DataGridViewRow
For i = 0 To gdStudInfo.RowCount - 1
dr = gdStudInfo.Rows(i)
att = dr.Cells(0).Value.ToString()
If att.Equals("Present") Then
qry = "insert into Stu_Att_Detail values(" & id & "," & gdStudInfo.Rows(i).Cells(1).Value.ToString() & ",'" & dr.Cells(0).Value.ToString() & "')"
con.MyQuery(qry)
End If
Next
I am getting correct values for all checked check box, but it gets error when the checkbox is not checked.
What if you try this?
If Not String.IsNullOrEmpty(dr.Cells(0).Value) Then
'do stuff here
End If
I know how to iterate through non-recurring appointments in Outlook.
My question is, how to I iterate through Outlook appointments including the recurring appointments?
Thank you.
If you are open to using 3rd party libraries, I'd suggest using "Redemption" library (http://www.dimastr.com/redemption/). This library has useful RDOFolder2 interface with GetActivitiesForTimeRange method.
Here you can find more information about usage of this interface:
(http://www.dimastr.com/redemption/rdo/rdofolder.htm)
If you don't want to use 3rd party library and need to stick to Outlook API, the trick is to set IncludeRecurrences flag to true before iterating appointments. The following article should provide enough information on how to do that:
(http://www.outlookcode.com/article.aspx?id=30)
Actually there is no need to use third party tools. There is the option IncludeRecurrences which takes care of this:
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set MyFolder = myNameSpace.GetDefaultFolder(olFolderCalendar)
Set oItems = MyFolder.Items
' Restrict Date
strFilter = "[Start] >= " + "'" + ourStart + "'"
Set oItems = oItems.Restrict(strFilter)
strFilter = "[End] <= " + "'" + ourEnd + "'"
Set oItems = oItems.Restrict(strFilter)
' Restrict Category
strFilter = "[Categories] = " + "'" + ourCategory + "'"
Set oItems = oItems.Restrict(strFilter)
oItems.Sort "[Start]"
' We want recurring, too (http://www.pcreview.co.uk/forums/get-recurring-appointment-dates-vba-t799214.html)
oItems.IncludeRecurrences = True