SSIS production package doesn't show some changes - scripting

I have an SSIS package that detects test domains from a data set being passed through the pipeline. I use a Scripting Component to send an e-mail notification listing the domains that have been marked as test domains. When I first posted the package with the notification, it sent a separate e-mail for each domain, after receiving to many e-mails, I changed the script to send a single e-mail with a list of the test domains. However each time I publish this update, it continues to send a single notification for each test domain.
Things I have looked into:
The content of the first e-mail and the second e-mail are different. So I did a "Find in Files" search in Notepad++ to see if I could find where the original e-mail content might be stored. There were no results found containing the original content.
I have disable the step which sends the notifications and published the package. This results in no notification e-mails being sent. However when I re-enable the step and publish, the original notifications sending a single e-mail for each test domains starts again.
I have tried dropping the SQL job that executes this package and recreating it but still the original notifications come through.
So with no trace of the original content even found on the production server, I do not know where this is coming from. I don't see anything about where the content could be cached, but even if it was being cached, then when I disabled the notification step, it would have still sent the notifications.
I am worried that if this can't be fixed, then does this mean there are other packages that are not being fully updated?
Any ideas or help would be greatly appreciated.
This is pretty much how the Scripting Component is setup...
Public Class ScriptMain
Inherits UserComponent
Private strDomains As String = String.Empty
Public Overrides Sub PreExecute()
MyBase.PreExecute()
End Sub
Public Overrides Sub PostExecute()
If strDomains.Length > 0 Then
Dim myHtmlMessage As MailMessage
Dim mySmtpClient As SmtpClient
Dim strMessageBody As New StringBuilder
strMessageBody.AppendLine("The listed domains have blah blah blah...")
strMessageBody.Append(strDomains)
strMessageBody.AppendLine(String.Empty)
strMessageBody.AppendLine("Love and Kisses,")
strMessageBody.AppendLine("Your Loving ETL Package")
strMessageBody.AppendLine(Variables.PackageName)
myHtmlMessage = New MailMessage("ETLNotices#company.com", "me#company.com", "Possible Test Domains", strMessageBody.ToString)
mySmtpClient = New SmtpClient("smtp.company.com")
mySmtpClient.Credentials = CredentialCache.DefaultNetworkCredentials
mySmtpClient.Send(myHtmlMessage)
End If
MyBase.PostExecute()
End Sub
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
Dim str As New StringBuilder
str.AppendLine(strDomains)
str.AppendFormat("{0}", Row.DomainName)
strDomains = str.ToString
End Sub
End Class

Chris,
I have some questions:
I guess you are using looping mechanism in your script task to iterate through all the domains ; find test ones among them; append them to a string and at the end send out an email. Is this correct?
Are you sending the mail in the script or created a separate Send Mail task?
Is the body of the your mail coming from some variable from config file?

Related

Activate Out of Office reply

I would like to automate my Out of Office based on the days that I'll be out on a biweekly basis. I don't have access to the Exchange server that hosts our Outlook.
I set an Outlook rule to send a automatic reply on Monday and apply VBA code to disable this rule when I'm in the office (with Outlook open). This is not an elegant way because the rule sends a reply to the user repeatedly every time an email is sent to me.
How can I activate my Out of Office reply on Outlook 2010 using VBA?
Here are the two resources I used:
https://answers.microsoft.com/en-us/msoffice/forum/msoffice_outlook-mso_win10/set-up-recurring-out-of-office-auto-reply-for/71dd1fef-ba99-4a2b-be72-7d509e8848eb
https://superuser.com/questions/292426/outlook-2010-how-to-turn-out-of-office-on-automatically-when-outlook-is-closed
This is the script I have in "ThisOutlookSession" to enable/disable the rule, "HomeTime" containing my Out Of Office-like message.
Option Explicit
Private Sub Application_Quit()
SetRuleEnabled True
End Sub
Private Sub Application_Startup()
SetRuleEnabled False
End Sub
Private Sub SetRuleEnabled(ByVal bEnable As Boolean)
Dim oSession As Outlook.NameSpace
Dim oRule As Outlook.Rule
Dim oRules As Outlook.Rules
Dim oPA As Outlook.PropertyAccessor
Set oSession = Application.Session
Set oRules = oSession.DefaultStore.GetRules()
Set oPA = oSession.DefaultStore.PropertyAccessor
'*** If the Out-Of-Office is already on (eg. holidays, sick leave etc.)
'*** then it might be best to force this rule permanently off
If oPA.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x661D000B") Then
bEnable = False
End If
For Each oRule In oRules
If oRule.Name = "HomeTime" Then
oRule.Enabled = bEnable
oRules.Save
Exit For
End If
Next
End Sub
I am assuming you've checked out Om3r's link, but I have a less elegant, if not clunky solution. I once created a VBA out of office message as a practical joke (just to avoid someone). I could not find the code, but here is a summary of what you'd need to do.
(Outlook has to be running for this to work)
Create a public boolean variable, for example OutofOffice, set by a ribbon/QAT button or on a schedule.
Create and save a draft email with your message (e.g. "I am out of the office...")
Use or set up an Inbox_ItemAdd event listener, and for each incoming email:
Reply to it,
concatenating "Auto-Reply " to the subject line
Retrieve the draft email and concatenate your draft message body to the reply body (and you'll have to figure out HTMLBody versus (non-HTML) Body. Something like:
OutMail.HTMLBody = OutMail.HTMLBody & ObjDraft.HTMLBody
or you might save your OOO message as a public static string (instead of a draft email).
Send the email
as you mentioned, you don't want to repeatedly send this to people who sent you additional emails during this period. I would probably add the sender's email address (after passing to a GetSMTPAddress type function) to an array. I'd add a IsInArray type function to check each new sender (to see if they were emailed already). This array would be erased by your procedure called when you click that control again to turn off the OOO reply.
If this worked for you, of course you could create a userform to edit the OOO message and set the schedule (day of week or specific dates).

Stop multiple PCs running same script for generic mailbox

I made a script to auto forward messages (with custom response) and, from what i gathered, it has to be on a running Outlook for it to be working.
The issue is that if a couple of machines are running that script will it "go off" multiple times?
from specific sender
containing XYZ in subject
except when it contains ABC in subject
Public Sub FW(olItem As Outlook.MailItem)
Dim olForward As Outlook.MailItem
Set olForward = olItem.Forward
With olForward
'Stuff happens here that work properly
End With
End If
'// Clean up
Set olItem = Nothing
Set olForward = Nothing
End Sub
As #Barney comment is absolutely correct and multiple runs of the script will trigger multiple forward of the item, I would like to add what you should do to perform your action once.
In the script right after successful forward of the message you should add a custom property into the item. The property will just indicate that the message was already forwarded (may be parsed/touched by your script). Now make the condition for entire item handling and check this property exists. If it does, do not perform any actions. The following resource will help with custom properties: How To: Add a custom property to the UserProperties collection of an Outlook e-mail item

Sending Lotus/IBM Notes email from Excel VBA - embedded chart image and attachment, specify From address

I am new to a Notes environment, so I've spent a lot of time reading here and other forums in an attempt to learn how to VBA an email via Lotus/IBM Notes.
There seems to be 2 main approaches; I am using the NotesUI method, since one of the requirements for the email is to embed an image of a portion of the Excel worksheet, as well as attaching the file itself.
At this stage, I have functioning code which achieves this (more often than not!) from the email address of the person who runs the macro. I can claim no credit for this - it has been borrowed with gratitude from the web.
However, the team has a shared email account, from which I wish to send the email.
I have seen some discussion of Principal and being able to specify a FromName, but I've so far been unable to achieve this last part.
The code I am using to successfully send an email with an attachment and an image of a section of my worksheet is below - and tips on how to modify the existing code to send from another email address would be most welcomed!
Sub SendEmbedMail(mailTo As String, stSubject As String, _
copyData As Range, Optional msgBeforeEmbed As String, _
Optional msgAfterEmbed As String, Optional attachFile As Workbook)
Dim Notes As Object, db As Object, WorkSpace As Object
Dim UIdoc As Object, UserName As String, MailDbName As String
Dim AttachMe As Object, EmbedObj As Object
'Create & Open New Document
Set WorkSpace = CreateObject("Notes.NotesUIWorkspace")
Call WorkSpace.COMPOSEDOCUMENT(, , "Memo")
Set UIdoc = WorkSpace.CURRENTDOCUMENT
Call UIdoc.inserttext(mailTo)
Call UIdoc.gotofield("Body")
Call UIdoc.inserttext(msgBeforeEmbed)
copyData.CopyPicture
Call UIdoc.Paste
Call UIdoc.inserttext(msgAfterEmbed)
Call UIdoc.gotofield("Subject")
Call UIdoc.inserttext(stSubject)
If Not attachFile Is Nothing Then
Set AttachMe = UIdoc.Document.CreateRichTextItem("Attachment")
Set EmbedObj = AttachMe.EmbedObject(1454, vbNullString, _
attachFile.FullName, "Attachment")
End If
Call UIdoc.Send(0, mailTo)
End Sub
Writing the document directly to the server's mail.box file is often used as a solution for this. See the first answer to this question, and look at the code of the OpenNTF Team Mailbox project for more details. Doing this generally won't completely remove the sender's info from the message, though. (It may vary depending on the Notes and Domino versions, but Notes has never been fully cooperative with spoofing attempts done this way.)
If you want to completely hide the identity of the sender, the approach that works best is to use an agent running on the server to send the message - or in your case, to re-send it. The agent can be signed by a generic Notes id instead of the developer's or the server's id, so by the time the actual send to the actual recipient occurs, the end-user isn't part of the process. In your case, you could accomplish that by creating a mail-in database and changing your VBA code from Call UIdoc.inserttext(mailTo) to Call UIdoc.inserttext("My mail-in database name goes here") but you'll also have to put your mailTo value somewhere, otherwise the agent won't know where to re-send it. You can do that by adding a line of code like this:
Call UIdoc.Document.ReplaceItemValue("actualRecipient",mailTo)
Your agent can be set up to run after new mail arrives in the mail-in database, and it can then clean up the message by removing the From and ReplyTo and INETFrom (if they exist - see here) items, and setting the SendTo and Principal and INETFrom fields. Omitting the basic framework code for the agent (some examples here) and assuming that doc is the variable that contains the NotesDocument that you are re-sending, the actual working part of the agent could be similar to this:
doc.RemoveItem("From")
doc.RemoveItem("InetFROM")
doc.RemoveItem("ReplyTo")
if doc.hasItem("actualRecipient") then
doc.ReplaceItemValue("SendTo",doc.actualRecipient(0))
doc.RemoveItem("actualRecipient")
else
' here you'll want to do something sensible if a message arrives in the mail-in
' database but it doesn't have an actualRecipient; i.e., it wasn't sent by your
' VBA code!
End if
Call doc.ReplaceItemValue("Principal","support#company.com#Your Notes Domain Goes Here <support#company.com>")
Call doc.ReplaceItemValue("INETFrom", "support#company.com")
Call doc.Send()
You could also do this using back-end classes (not UI). I wrote a class to help with creating emails, it includes changing the from-address to anything you like:
http://blog.texasswede.com/lotusscript-mail-notification-class/
You just have to add a method to insert a picture in the text, you can use the approach described by Thomas Hampel at http://blog.tomcat2000.com/blog/tomcat2000.nsf/dx/notesapi-import-pictures-into-richtext-fields-using-backend-classes.htm.

Download Report and attach to email

I would like to ask if anyone knows the thing that i want to do:
I have a report in microsoft report server that's waiting for a parameter (person_id) to make the fulfill.
I need to send an email with the report of each person_id. I need to run a function that runs my report called per_permissions.rdl download it and attached the file to send it by email. Example in vb.net code
strSql = "SELECT per_id,per_email FROM person"
dt_person = getDataTable(strSql)
For each dr_person As DataRow in dt_persona.Rows
attached_file = mysticFunction(dr_person("per_id"))
...
Next
Public Shared Sub DownloadFile(ByVal _URL As String, ByVal _SaveAs As String)
Try
Dim _WebClient As New System.Net.WebClient()
_WebClient.DownloadFile(_URL, _SaveAs)
Catch _Exception As Exception
Console.WriteLine("Exception caught in process: {0}", _Exception.ToString())
End Try
End Sub
Yes, it is fairly simple. Using the ReportExecutionService.Render method you can render the report however you want. We've used this to run reports and attach them to emails automatically.
The MSDN site has some code to get you started.
To add a reference to the report execution web service, right-click References, select Add Service Reference... and add a reference to the web service that will look something like:
http://MyReportServer/ReportServer/ReportExecution2005.asmx
You will also need the report service web service, which is:
http://MyReportServer/ReportServer/ReportService2005.asmx

How do I make Outlook purge a folder automatically when anything arrives in it?

I hope it's okay to ask this kind of question. Attempting to write the code myself is completely beyond me at the moment.
I need a macro for Outlook 2007 that will permanently delete all content of the Sent Items folder whenever anything arrives in it. Is it possible? How do I set everything up so that the user doesn't ever have to click anything to run it?
I know I'm asking for a fish, and I'm embarrassed, but I really need the thing...
edit:
I've pasted this into the VBA editor, into a new module:
Public Sub EmptySentEmailFolder()
Dim outApp As Outlook.Application
Dim sentFolder As Outlook.MAPIFolder
Dim item As Object
Dim entryID As String
Set outApp = CreateObject("outlook.application")
Set sentFolder = outApp.GetNamespace("MAPI").GetDefaultFolder(olFolderSentMail)
For i = sentFolder.Items.Count To 1 Step -1
sentFolder.Items(i).Delete '' Delete from mail folder
Next
Set item = Nothing
Set sentFolder = Nothing
Set outApp = Nothing
End Sub
It's just a slightly modified version of a piece of code I found somewhere on this site deleting Deleted Items. It does delete the Sent Items folder when I run it. Could you please help me modify it in such a way that it deletes Sent Items whenever anything appears in the folder, and in such a way that the user doesn't have to click anything to run it? I need it to be a completely automated process.
edit 2: Please if you think there's a better tool to achieve this than VBA, don't hesitate to edit the tags and comment.
edit 3: I did something that works sometimes, but sometimes it doesn't. And it's ridiculously complicated. I set a rule that ccs every sent email with an attachment to me. Another rule runs the following code, when an email from me arrives.
Sub Del(item As Outlook.MailItem)
Call EmptySentEmailFolder
End Sub
The thing has three behaviors, and I haven't been able to determine what triggers which behavior. Sometimes the thing does purge the Sent Items folder. Sometimes it does nothing. Sometimes the second rule gives the "operation failed" error message.
The idea of acting whenever something comes from my address is non-optimal for reasons that I'll omit for the sake of brevity. I tried to replace it with reports. I made a rule that sends a delivery report whenever I send an email. Then another rule runs the code upon receipt of the report. However, this has just one behavior: it never does anything.
Both ideas are so complicated that anything could go wrong really, and I'm having trouble debugging them. Both are non-optimal solutions too.
Would this be an acceptable solution? Sorry its late but my copy of Outlook was broken.
When you enter the Outlook VB Editor, the Project Explorer will be on the left. Click Ctrl+R if it isn't. It will look something like this:
+ Project1 (VbaProject.OTM)
or
- Project1 (VbaProject.OTM)
+ Microsoft Office Outlook Objects
+ Forms
+ Modules
"Forms" will be missing if you do not have any user forms. It is possible "Modules" is expanded. Click +s as necessary to get "Microsoft Office Outlook Objects" expanded:
- Project1 (VbaProject.OTM)
- Microsoft Office Outlook Objects
ThisOutlookSession
+ Forms
+ Modules
Click ThisOutlookSession. The module area will turn white unless you have already used this code area. This area is like a module but have additional privileges. Copy this code to that area:
Private Sub Application_MAPILogonComplete()
' This event routine is called automatically when a user has completed log in.
Dim sentFolder As Outlook.MAPIFolder
Dim entryID As String
Dim i As Long
Set sentFolder = CreateObject("Outlook.Application"). _
GetNamespace("MAPI").GetDefaultFolder(olFolderSentMail)
For i = sentFolder.Items.Count To 1 Step -1
sentFolder.Items(i).Delete ' Move to Deleted Items
Next
Set sentFolder = Nothing
End Sub
I have taken your code, tidied it up a little and placed it within an event routine. An event routine is automatically called when the appropriate event occurs. This routine is called when the user has completed their log in. This is not what you requested but it might be an acceptable compromise.
Suggestion 2
I have not tried an ItemAdd event routine on the Sent Items folder before although I have used it with the Inbox. According to my limited testing, deleting the sent item does not interfere with the sending.
This code belongs in "ThisOutlookSession".
Option Explicit
Public WithEvents MyNewItems As Outlook.Items
Private Sub Application_MAPILogonComplete()
Dim NS As NameSpace
Set NS = CreateObject("Outlook.Application").GetNamespace("MAPI")
With NS
Set MyNewItems = NS.GetDefaultFolder(olFolderSentMail).Items
End With
End Sub
Private Sub myNewItems_ItemAdd(ByVal Item As Object)
Debug.Print "--------------------"
Debug.Print "Item added to Sent folder"
Debug.Print "Subject: " & Item.Subject
Item.Delete ' Move to Deleted Items
Debug.Print "Moved to Deleted Items"
End Sub
The Debug.Print statements show you have limited access to the sent item. If you try to access more sensitive properties, you will trigger a warning to the user that a macro is assessing emails.