how to find the attachment filename which is getting deleted
both ItemAttachmentDeleted, ItemAttachmentDeleting events afterproperties and beforeproperties are empty
use
string beforeUrl = properties.BeforeUrl;
string[] fileName = beforeUrl.Split('/');
string deletedfile = fileName[fileName.Length - 1];
below code gives us first attachment Name
SPFile attachment = properties.ListItem.ParentList.RootFolder.
SubFolders["Attachments"].SubFolders[properties.ListItemId.ToString()].
Files[properties.ListItem.Attachments.Count - 1];
string link = attachment.Name ;
Related
I wants to generate XML string something like this in swift -
<userTracking>
<userDetail id='1178085'>xxxx</userDetail>
<trackInfo type="xxxxx" type_id="xxxxxxx" attending="x" event_date="2016-07-01"/>
</userTracking>
for this i had objective-C code -
NSString *post = #"";
post = [NSString stringWithFormat:
#"<userTracking>"
#"<userDetail id=\'%#\'>xxxxx</userDetail>"
#"<trackInfo type=\"%#\" type_id=\"%#\" attending=\"%#\" event_date=\"%#\"/>"
#"</userTracking>"
, UserID,type, typeID, attending,event_date];
which is working great. Now i wants to generate same thing in swift & done following code but getting wrong XML formatted string -
swift Code -
var post = "";
post = "<userTracking>" +
"<userDetail id='\(UserID)\'>xxxxx</userDetail>" +
"<trackInfo type=\"\(type)\" type_id=\"\(typeID)\" attending=\"\(attending)\" event_date=\"\(event_date)\"/>" +
"</userTracking>";
Result in Swift -
<userTracking>
<userDetail id=\'xxxxx\'>xxxxx</userDetail>
<trackInfo type=\"xxxx\" type_id=\"xxx\" attending=\"4\" event_date=\"2016-07-01\"/>
</userTracking>
any help will be appreciated.
You can also use String(format:) in Swift.
Don't forget to escape all double quotes, and add newlines ("\n") and tabs ("\t") if needed.
Example:
let post = String(format: "<userTracking>\n\t<userDetail id=\'%#\'>xxxxx</userDetail>\n\t<trackInfo type=\"%#\" type_id=\"%#\" attending=\"%#\" event_date=\"%#\"/>\n</userTracking>", UserID, type, typeID, attending, event_date)
Gives:
<userTracking>
<userDetail id='...'>xxxxx</userDetail>
<trackInfo type="..." type_id="..." attending="..." event_date="..."/>
</userTracking>
i am trying to load textfield value in to mutable array using add object method but that value is not in string formate.i enter the array structure in below. thank you.
{
ItemUPC = rr001; ------->>>>>in this place
ItemUnits = "";
Itemcost = "";
}
i expected this structure
{
ItemUPC = "rr001"; ------->>>>>in this place
ItemUnits = "";
Itemcost = "";
}
thankyou
Try with this:
[NSString stringWithFormat:#"%#", yourtextField.text];
in both cases it IS actually a string. the problem is that NSLog() only shows the "" signs if it is an empty string or if there are some spaces within the string!
you can check it like this:
for (id object in yourArrayName) {
NSLog(#"%#", [object class]);
}
if the object IS a string it should say something like __NSCFConstantString.
I'm new to Objective-C. Here is my question:
In my two string files are the following two entries:
(German string file)
/* Class = "IBUILabel"; text = "Import to DoS"; ObjectID = "GfF-rD-aDa"; */
"GfF-rD-aDa.text" = "Zu DT %lu importieren";
(English string file)
/* Class = "IBUILabel"; text = "Import to DoS"; ObjectID = "GfF-rD-aDa"; */
"GfF-rD-aDa.text" = "Import to DoS %lu";
My code looks like:
self.importLabel.text = [NSString localizedStringWithFormat:NSLocalizedString(#"GfF-rD-aDa.text", nil), projectday];
According to Apples Documentation NSLocalizedString needs a key and a comment. That's why I putted #"GfF-rD-aDa.text" into the first parameter because it's the same key like in my strings file.
So I want it to generate strings like:
"Zu DT 2 importieren"
and
"Import to DoS 2"
but it doesn't work. The output text is:
"GfF-rD-aDa.text"
I'm not allowed to change the key in the strings table because we use a script to generate all these entries based on the object id.
Regards
Try using this specify your strings file in NSLocalizedStringFromTable macro.
self.importLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(#"GfF-rD-aDa.text", #"yourStringsFile", #"comment"), projectday];
Try this:
self.importLabel.text = [NSString stringWithFormat:NSLocalizedString(#"GfF-rD-aDa.text", nil), projectday];
I made an xcode project in which I logged the JSON from a YQL query. This is the output I get:
quote = {
AverageDailyVolume = 22235800;
Change = "+0.03";
DaysHigh = "36.60";
DaysLow = "35.55";
DaysRange = "35.55 - 36.60";
LastTradePriceOnly = "36.38";
MarketCapitalization = "37.523B";
Name = "Yahoo! Inc.";
StockExchange = NasdaqNM;
Symbol = YHOO;
Volume = 28937796;
YearHigh = "41.72";
YearLow = "23.47";
symbol = YHOO;
};
}
What i want to do is take a single line from this code. for example: "LastTradePriceOnly ="36.38"". Then i want to be able to store the value of LastTradePriceOnly (36.38) in a NSNumber/NSInteger.
the code i have in my project is mainly:
- (IBAction)enterButton2:(id)sender {
NSString *query2 = (self.queryText2.text);
NSDictionary *results2 = [yql query:query2];
NSString *respond2 = [[results2 valueForKeyPath:#"query.results"]description];
self.resultView2.text = respond2;
NSLog(#"%#",respond2);}
the query i used is placed in a textView, the query is :
select * from yahoo.finance.quote where symbol in ("YHOO")
thanks to #Larme i tried to use this method:
[[yourObject objectForKey:#"quote"] objectForKey:#"LastTradePriceOnly"]
but i couldnt get it to work.
help is much appreciated.
The solution:
Ok, so you put your response (respond2) into an NSString. That's quite strange. Let's restart from something that was a NSArray or a NSDictionary: [results2 valueForKeyPath:#"query.results"]:
[[[results2 valueForKeyPath:#"query.results"] objectForKey:#"quote"] objectForKey:#"LastTradePriceOnly"];
I have problem with an embedded image in email. When receiving mail I show image in attachment instead of message body and I have add image dynamically in message body. And also I have set "cid" but I have not success. I have set ishtmlbody = true but not showing image in body. please solve my problem.
My code is here:
This is my body message:
const string to = "test#gmail.com";
msg.To.Add(to);
msg.From = new MailAddress("test#gmail.com");
msg.Subject = "test";
int count = 1;
int stratindex = 0;
//Create altenative view
AlternateView alternative = AlternateView.CreateAlternateViewFromString(strMailContent, null, MediaTypeNames.Text.Html);
while ((lastIndex = strMailContent.IndexOf(findStr, stratindex, StringComparison.Ordinal)) != -1)
{
int srcStartIndex =Convert.ToInt32(strMailContent.IndexOf("src", lastIndex, StringComparison.Ordinal)) + 5;
int srcEndIndex = strMailContent.IndexOf(#"'", srcStartIndex, StringComparison.Ordinal);
string imgSrc = strMailContent.Substring(srcStartIndex, srcEndIndex - srcStartIndex);
string path = imgSrc;
// Atteched resource
// set cid
var resource = new LinkedResource(path, "image/jpg");
string cid = "companylogo" + count;
//now add the AlternateView
resource.ContentId = cid;
alternative.LinkedResources.Add(resource);
msg.AlternateViews.Add(alternative);
//now append it to the body of the mail
strMailContent = strMailContent.Replace(strMailContent.Substring(srcStartIndex, srcEndIndex - srcStartIndex), "cid:" + cid);
stratindex = strMailContent.IndexOf("<br/>", lastIndex, StringComparison.Ordinal) + 5;
strMailContent = strMailContent.Remove(stratindex - 5, 5);
stratindex = stratindex - 5;
count++;
}
show in screen short red area show the attachment and yellow area show blank body.
how to solve this problem.
I don't see any problems in your code, you have to ensure the path file is correct