File Coverage

blib/lib/Win32/SqlServer/DTS/Task/SendEmail.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package Win32::SqlServer::DTS::Task::SendEmail;
2            
3             =head1 NAME
4            
5             Win32::SqlServer::DTS::Task::SendEmail - a subclass of Win32::SqlServer::DTS::Task that represents a DTSSendMailTask object.
6            
7             =head1 SYNOPSIS
8            
9             use warnings;
10             use strict;
11             use Win32::SqlServer::DTS::Application;
12             use Test::More;
13             use XML::Simple;
14            
15             my $xml = XML::Simple->new();
16             my $config = $xml->XMLin('test-config.xml');
17            
18             my $app = Win32::SqlServer::DTS::Application->new( $config->{credential} );
19            
20             my $package = $app->get_db_package(
21             {
22             id => '',
23             version_id => '',
24             name => $config->{package},
25             package_password => ''
26             }
27             );
28            
29             my $iterator = $package->get_send_emails();
30            
31             while ( my $send_mail = $iterator->() ) {
32            
33             print $send_mail->to_string, "\n";
34            
35             }
36            
37            
38             =head1 DESCRIPTION
39            
40             C represents a DTS SendMail task object.
41            
42             =head2 EXPORT
43            
44             Nothing.
45            
46             =cut
47            
48 1     1   27126 use strict;
  1         3  
  1         141  
49 1     1   7 use warnings;
  1         2  
  1         37  
50 1     1   6 use Carp;
  1         1  
  1         101  
51 1     1   6 use base qw(Win32::SqlServer::DTS::Task Class::Accessor);
  1         1  
  1         648  
52             use Hash::Util qw(lock_keys);
53            
54             =head2 METHODS
55            
56             All methods from L are also available.
57            
58             =cut
59            
60             __PACKAGE__->follow_best_practice;
61             __PACKAGE__->mk_ro_accessors(
62             qw(message_text cc_line attachments profile_password profile subject to_line)
63             );
64            
65             our %attrib_convertion = (
66             cc_line => 'CCLine',
67             attachments => 'FileAttachments',
68             message_text => 'MessageText',
69             profile_password => 'Password',
70             profile => 'Profile',
71             save_sent => 'SaveMailInSentItemsFolder',
72             is_nt_service => 'IsNTService',
73             subject => 'Subject',
74             to_line => 'ToLine'
75             );
76            
77             =head3 new
78            
79             Overrides the superclass C method C to define the following attributes:
80            
81             =over
82            
83             =item *
84            
85             cc_line
86            
87             =item *
88            
89             attachments
90            
91             =item *
92            
93             message_text
94            
95             =item *
96            
97             profile_password
98            
99             =item *
100            
101             profile
102            
103             =item *
104            
105             save_sent
106            
107             =item *
108            
109             is_nt_service
110            
111             =item *
112            
113             subject
114            
115             =item *
116            
117             to_line
118            
119             =back
120            
121             =cut
122            
123             sub new {
124            
125             my $class = shift;
126             my $self = $class->SUPER::new(@_);
127            
128             my $sibling = $self->get_sibling();
129            
130             foreach my $attrib ( keys(%attrib_convertion) ) {
131            
132             $self->{$attrib} = $sibling->{ $attrib_convertion{$attrib} };
133             }
134            
135             lock_keys( %{$self} );
136            
137             return $self;
138            
139             }
140            
141             =head3 is_nt_service
142            
143             Returns true or false (1 or 0) whether the caller is a Microsoft Windows NT 4.0 or Microsoft Windows 2000
144             Service. Returns true only if the program that calls the package Execute method is installed as a
145             Windows NT 4.0 or Windows 2000 Service.
146            
147             =cut
148            
149             sub is_nt_service {
150            
151             my $self = shift;
152             return $self->{is_nt_service};
153            
154             }
155            
156             =head3 save_sent
157            
158             Returns true or false (1 or 0) whether to save outgoing e-mail messages in the Sent Items folder.
159            
160             =cut
161            
162             sub save_sent {
163            
164             my $self = shift;
165             return $self->{save_sent};
166            
167             }
168            
169             =head3 to_string
170            
171             Overrides superclass C method C to return strings for all defined attributes
172             of the object.
173            
174             =cut
175            
176             sub to_string {
177            
178             my $self = shift;
179            
180             my $properties_string =
181             "\tName: "
182             . $self->get_name
183             . "\r\n\tDescription: "
184             . $self->get_description
185             . "\r\n\tCC line: "
186             . $self->get_cc_line
187             . "\r\n\tAttachments: "
188             . $self->get_attachments
189             . "\r\n\tIs a NT service? "
190             . ( ( $self->is_nt_service ) ? 'true' : 'false' )
191             . "\r\n\tMessage:\r\n"
192             . $self->get_message_text
193             . "\r\n\tProfile password: "
194             . $self->get_profile_password
195             . "\r\n\tProfile: "
196             . $self->get_profile
197             . "\r\n\tSave message in sent folder? "
198             . ( ( $self->save_sent ) ? 'true' : 'false' )
199             . "\r\n\tSubject: "
200             . $self->get_subject
201             . "\r\n\tTo line: "
202             . $self->get_to_line;
203            
204             return $properties_string;
205            
206             }
207            
208             1;
209            
210             __END__