I want to subscribe report on specific schedule in reporting services 2008. i.e report will dilever to user automatically on schedule. I am using visual studio 2008. I have done the configuration setting (rsreportserver.config, app.config after adding refrences of asmx files) by refrence msdn. The code is running fine (no exception occur) and I also get subscription id through calling create subscription indicate all going fine. But after running the code no entry made in Subscription table of ReportServer database. And also not get any mail. While through report server web tool, I can get email and also entery made in database but not from coe. Please someone help me. What I am missing. Plz help
Code is given follow: (Keep in mind, I am using VS2008)
void SendReportEmail()
{
RSServiceReference.ReportingService2005SoapClient rs=new RSServiceReference.ReportingService2005SoapClient();
rs.ClientCredentials.Windows.AllowedImpersonationLevel = new System.Security.Principal.TokenImpersonationLevel();
string batchID = string.Empty;
RSServiceReference.ServerInfoHeader infoHeader = rs.CreateBatch(out batchID);
BatchHeader bh = new BatchHeader()
{
BatchID = batchID,
AnyAttr = infoHeader.AnyAttr
};
string report = "/PCMSR6Reports/PaymentRequestStatusMIS";
string desc = "Send email from code to Hisham#comsoft.com";
string eventType = "TimedSubscription";
string scheduleXml="<ScheduleDefinition xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><StartDateTime xmlns=\"http://schemas.microsoft.com/sqlserver/2006/03/15/reporting/reportingservices\">2010-03-06T15:15:00.000+05:00</StartDateTime></ScheduleDefinition>";
RSServiceReference.ParameterValue[] extensionParams = new RSServiceReference.ParameterValue[7];
extensionParams[0] = new RSServiceReference.ParameterValue();
extensionParams[0].Name = "TO";
extensionParams[0].Value = "Hisham#comsoft.com";
extensionParams[1] = new RSServiceReference.ParameterValue();
extensionParams[1].Name = "IncludeReport";
extensionParams[1].Value = "True";
extensionParams[2] = new RSServiceReference.ParameterValue();
extensionParams[2].Name = "RenderFormat";
extensionParams[2].Value = "MHTML";
extensionParams[3] = new RSServiceReference.ParameterValue();
extensionParams[3].Name = "Subject";
extensionParams[3].Value = "#ReportName was executed at #ExecutionTime";
extensionParams[4] = new RSServiceReference.ParameterValue();
extensionParams[4].Name = "Comment";
extensionParams[4].Value = "Here is your test report for testing purpose";
extensionParams[5] = new RSServiceReference.ParameterValue();
extensionParams[5].Name = "IncludeLink";
extensionParams[5].Value = "True";
extensionParams[6] = new RSServiceReference.ParameterValue();
extensionParams[6].Name = "Priority";
extensionParams[6].Value = "NORMAL";
RSServiceReference.ParameterValue[] parameters = new RSServiceReference.ParameterValue[10];
parameters[0] = new RSServiceReference.ParameterValue();
parameters[0].Name = "BranchId";
parameters[0].Value = "1";
parameters[1] = new RSServiceReference.ParameterValue();
parameters[1].Name = "UserName";
parameters[1].Value = "admin";
parameters[2] = new RSServiceReference.ParameterValue();
parameters[2].Name = "SupplierId";
parameters[2].Value = "0";
string matchData = scheduleXml;
RSServiceReference.ExtensionSettings extSettings = new RSServiceReference.ExtensionSettings();
extSettings.ParameterValues = extensionParams;
extSettings.Extension = "Report Server Email";
try
{
string sub="";
RSServiceReference.ServerInfoHeader SubID = rs.CreateSubscription(bh, report, extSettings, desc, eventType, matchData, parameters, out sub);
rs.FireEvent(bh, "TimedSubscription", sub);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
Detail response will be highly appricated.
Try adding # at the beginning of your xml string #"
Related
I have a task for executions to send a file that has been downloaded from the database
and I will have to send the file by e-mail with the name of the time the file was sent.
what would be the order of execution of this task in integrated services
with the use of file system task and send email task in ssis.
No doubt, you should create your with file system task at first and save it where you wish. after that with using "Script Task" in control flow, you can send it easily. You just add these sources in "using namespaces" block:
"using System.Net.Mail;"
The Code you need to add in public main method should be like this:
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
string sSubject = [Your Subject Name String];
string sBody = [Your Body String];
string sEmailServer = [The Address of your Email Server];
string sEmailPort = [The Email Port];
string sEmailUser = [Your Email address];
string sEmailPassword = [Your Email Password];
string sEmailSendTo = [The Receiver Email];
string sEmailSendCC = [The CC Sender Email];
string sEmailSendFrom = [The Sender Email];
string sEmailSendFromName = [The Sender Name];
message.Priority = MailPriority.High;(Normal, Low, High).
MailAddress fromAddress = new MailAddress(sEmailSendFrom, sEmailSendFromName);
message.From = fromAddress;
string[] sEmailTo = Regex.Split(sEmailSendTo, ";");
string[] sEmailCC = Regex.Split(sEmailSendCC, ";");
int sEmailServerSMTP = int.Parse(sEmailPort);
smtpClient.Host = sEmailServer;
smtpClient.Port = sEmailServerSMTP;
smtpClient.EnableSsl = false;
System.Net.NetworkCredential myCredentials =
new System.Net.NetworkCredential(sEmailUser, sEmailPassword);
smtpClient.Credentials = myCredentials;
if (sEmailTo != null)
{
for (int i = 0; i < sEmailTo.Length; ++i)
{
if (sEmailTo[i] != null && sEmailTo[i] != "")
{
message.To.Add(sEmailTo[i]);
}
}
}
if (sEmailCC != null)
{
for (int i = 0; i < sEmailCC.Length; ++i)
{
if (sEmailCC[i] != null && sEmailCC[i] != "")
{
message.To.Add(sEmailCC[i]);
}
}
}
Attachment myAttachment = new Attachment([The path the file you saved]);
message.Attachments.Add(myAttachment);
message.Subject = sSubject;
message.IsBodyHtml = false;
message.Body = sBody;
smtpClient.Send(message);
Left side table is distorted while comparing two HTML table data using daisydiff.jar.
I need your support to fix this issue. Thanks in advance
Using below code
StringWriter finalResult = new StringWriter();
SAXTransformerFactory tf = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); TransformerHandler result = tf.newTransformerHandler();
result.getTransformer().setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
result.getTransformer().setOutputProperty(OutputKeys.INDENT, "no");
result.getTransformer().setOutputProperty(OutputKeys.METHOD, "html");
result.getTransformer().setOutputProperty(OutputKeys.ENCODING, "UTF-8");
result.setResult(new StreamResult(finalResult));
ContentHandler postProcess = result;
Locale locale = Locale.getDefault();
String prefix = "diff";
NekoHtmlParser cleaner = new NekoHtmlParser();
InputSource oldSource = new InputSource (new String reader(html1));
InputSource newSource = new InputSource (new String reader(html2));
DomTreeBuilder oldHandler = new DomTreeBuilder ();
cleaner.parse(oldSource, oldHandler);
TextNodeComparator leftComparator = new TextNodeComparator (oldHandler, locale);
DomTreeBuilder newHandler = new DomTreeBuilder ();
cleaner.parse(newSource, newHandler);
TextNodeComparator rightComparator = new TextNodeComparator (newHandler, locale);
HtmlSaxDiffOutput output = new HtmlSaxDiffOutput (postProcess, prefix);
HTMLDiffer differ = new HTMLDiffer(output);
differ.diff(leftComparator, rightComparator);
I've got this code that sends a simple email using SmtpClient, MailMessage, and MailAddress objects:
private void EmailMessage(string msg)
{
string TO_EMAIL = "cshannon#proactusa.com";
var windowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent();
string userName = windowsIdentity.Name;
string subject = string.Format("Log msg from Report Runner app sent {0}; user was {1}", DateTime.Now.ToLongDateString(), userName);
string body = msg;
var SmtpServer = new SmtpClient(ReportRunnerConstsAndUtils.EMAIL_SERVER);
var SendMe = new MailMessage();
SendMe.To.Add(TO_EMAIL);
SendMe.Subject = subject;
SendMe.From = new MailAddress(ReportRunnerConstsAndUtils.FROM_EMAIL);
SendMe.Body = body;
try
{
SmtpServer.UseDefaultCredentials = true;
SmtpServer.Send(SendMe);
}
}
I also need, though, to attach a file to an email. I was doing it using Outlook like so:
Application app = new Application();
MailItem mailItem = app.CreateItem(OlItemType.olMailItem);
. . .
FileInfo[] rptsToEmail = GetLastReportsGenerated();
foreach (var file in rptsToEmail)
{
String fullFilename = String.Format("{0}\\{1}", uniqueFolder, file.Name);
if (!file.Name.Contains(PROCESSED_FILE_APPENDAGE))
{
mailItem.Attachments.Add(fullFilename);
}
}
mailItem.Importance = OlImportance.olImportanceNormal;
mailItem.Display(false);
...but I need to move away from using Outlook for this. Here the MailItem is a Microsoft.Office.Interop.Outlook.MailItem
How can I add attachments in the simple MailMessage I need to use now?
Setting the Importance is not too important, I don't think, but the Display is something I will need to set for the MailMessage, too.
Easy:
if (!file.Name.Contains(PROCESSED_FILE_APPENDAGE))
{
var attachment = new Attachment(fullFilename);
mailMsg.Attachments.Add(attachment);
}
mailMsg.Priority = MailPriority.Normal;
I have researched for this issue and am unable to find a solution.
The SO post TimeZone change to UTC while updating the Appointment referred to the same problem, but I've tested the solution and its not working.
Here is what's wrong:
Does anyone have a solution? The time is correctly reflected on Outlook, Emails etc. It's just that the text shown is misleading to people and causing confusion.
*Note that the code below can be copied and pasted into a console app for testing.
var timezone = TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time");
var service = new ExchangeService(ExchangeVersion.Exchange2013, timezone);
service.Credentials = new NetworkCredential("myemail#mydomain.com", "mypassword");
service.Url = new Uri("https://outlook.office365.com/Ews/Exchange.asmx");
var meeting1 = new Appointment(service);
meeting1.Subject = "Test Meeting";
meeting1.Body = "Test body";
meeting1.Start = new DateTime(2013, 8, 22, 9, 0, 0); //my default time is GMT+8
meeting1.End = meeting1.Start.AddHours(2);
meeting1.Location = "Conf Room";
meeting1.RequiredAttendees.Add("someone#outlook.com");
meeting1.Save(SendInvitationsMode.SendToAllAndSaveCopy);
Console.WriteLine("1st invite sent");
var id = meeting1.Id.ToString();
System.Threading.Thread.Sleep(5000); //break for a while...
//re-fetch the appointment
var meeting2 = Appointment.Bind(service, new ItemId(id),
new PropertySet(BasePropertySet.IdOnly, AppointmentSchema.Start,
AppointmentSchema.End, AppointmentSchema.StartTimeZone,
AppointmentSchema.EndTimeZone, AppointmentSchema.TimeZone));
Console.WriteLine( meeting2.StartTimeZone ); //shows Tokyo Standard Time correctly.
meeting2.StartTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time");
meeting2.EndTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time");
meeting2.Start = new DateTime(2013,8,23, 9,0,0, DateTimeKind.Unspecified);
meeting2.End = meeting2.Start.AddHours(2);
meeting2.Subject = "Updated Test Meeting";
meeting2.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy);
meeting2.Load(new PropertySet(BasePropertySet.IdOnly, AppointmentSchema.Start,
AppointmentSchema.End, AppointmentSchema.StartTimeZone,
AppointmentSchema.EndTimeZone, AppointmentSchema.TimeZone,
AppointmentSchema.Body, AppointmentSchema.NormalizedBody,AppointmentSchema.TextBody));
Console.WriteLine( meeting2.StartTimeZone ); //shows Tokyo Standard Time correctly.
I've been having the same issue as we're using ExchangeVersion.Exchange2010_SP2 but i'm managed to get round this using:
appointment.Save(SendInvitationsMode.SendToNone);
// to fix the issue of updating appointment sets timezone to UTC, we use ExchangeVersion.Exchange2007_SP1
service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.UseDefaultCredentials = false;
service.Credentials = new WebCredentials(Account, Password);
service.Url = new Uri(url);
service.Timeout = 600000;
I am facing an issue with sending attachments with invitation using EWS Managed API. Appointments attendees are not receiving any attachments added to the appointment but
attachment do appears in the calendar of the person that created the appointment.
Here is my code snippet:
try
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));
service.Credentials = new WebCredentials("calendar_user", "password1", "acme");
service.Url = new Uri("https://acme.com/EWS/Exchange.asmx");
Appointment appointment = new Appointment(service);
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "tin.tin#acme.com");
String UID = "D09F3FF6-1461-414C-89E8-C05BC3B66A4A";
appointment.ICalUid = UID;
appointment.Subject = "Test Subject";
appointment.Body = "Test Content.";
appointment.Start = new DateTime(2012, 07, 11, 17, 00, 0);
appointment.End = appointment.Start.AddMinutes(30);
FileAttachment attachment = appointment.Attachments.AddFileAttachment(#"C:\Users\tintin\Documents\Test.xlsx");
attachment.IsInline = false;
appointment.RequiredAttendees.Add("tin.tin#acme.com");
appointment.Save(SendInvitationsMode.SendToAllAndSaveCopy);
}
catch (Exception ex)
{
}
Look like EWS has horrible limitation with attachment handling. I found a workaround to resolve this issue which requires updating appointment object twice.
appointment.ICalUid = UID;
appointment.Subject = "Test Subject";
appointment.Body = "Test Content.";
appointment.Start = new DateTime(2012, 07, 11, 17, 00, 0);
appointment.End = appointment.Start.AddMinutes(30);
FileAttachment attachment = appointment.Attachments.AddFileAttachment(#"C:\Users\tintin\Documents\Test.xlsx");
attachment.IsInline = false;
appointment.Save(folderCalendar, SendInvitationsMode.SendToNone);
appointment.RequiredAttendees.Add("tin.tin#acme.com");
appointment.Update(ConflictResolutionMode.AutoResolve, SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy);
Looks like this issue is specific to Exchange Server 2010 Service Pack 1. I got similar issue and when I changed the version to SP2 issue got resolved. Below code solved the problem
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
A second update did the trick, but it will cause a cancelled meeting at the bottom. Can't use it in product.
It doesn't work to change the version to SP2.
Still find a better solution.
Yes, EWS has some issue, while updating the meeting with new attachments it is not getting updated for the first time. Needed 2 instances to update it.
Microsoft.Exchange.WebServices.Data.Appointment meet1 = await
Microsoft.Exchange.WebServices.Data.Appointment.Bind(service, strMessageID);
meet1.Attachments.Clear();
foreach (FileUpload Item in
objCreateEvent.strAttachmentUploadPath)
{
meet1.Attachments.AddFileAttachment(Item.fileName,
Item.filePath);
}
meet1.RequiredAttendees.Clear();
foreach (string ToItem in objToIds)
{
meet1.RequiredAttendees.Add(ToItem);
}
await
meet1.Update(ConflictResolutionMode.AlwaysOverwrite,
SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy);
Microsoft.Exchange.WebServices.Data.Appointment
meeting2 = await Microsoft.Exchange.WebServices.Data.Appointment.Bind(service,
strMessageID);
meeting2.Attachments.Clear();
foreach (FileUpload Item in
objCreateEvent.strAttachmentUploadPath)
{
meeting2.Attachments.AddFileAttachment(Item.fileName, Item.filePath);
}
meeting2.RequiredAttendees.Clear();
foreach (string ToItem in objToIds)
{
meeting2.RequiredAttendees.Add(ToItem);
}
await
meeting2.Update(ConflictResolutionMode.AlwaysOverwrite,
SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy);