| 1 | package Email::Outlook::Message; | ||||||||||||||||||||||||||||
| 2 | =head1 NAME | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | Email::Outlook::Message.pm - Read Outlook .msg files | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | use Email::Outlook::Message; | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | my $msg = new Email::Outlook::Message $filename, $verbose; | ||||||||||||||||||||||||||||
| 11 | my $mime = $msg->to_email_mime; | ||||||||||||||||||||||||||||
| 12 | $mime->as_string; | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | Parses .msg message files as produced by Microsoft Outlook. | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =head1 METHODS | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | =over 8 | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =item B<new($msg, $verbose)> | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | Parse the file pointed at by $msg. Set $verbose to a true value to | ||||||||||||||||||||||||||||
| 25 | print information about skipped parts of the .msg file on STDERR. | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | =item B<to_email_mime> | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | Output result as an Email::MIME object. | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =back | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | =head1 BUGS | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | Not all data that is in the .msg file is converted. There are some | ||||||||||||||||||||||||||||
| 36 | parts whose meaning escapes me, although more documentation on MIME | ||||||||||||||||||||||||||||
| 37 | properties is available these days. Other parts do not make sense outside | ||||||||||||||||||||||||||||
| 38 | of Outlook and Exchange. | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | GPG signed mail is not processed correctly. Neither are attachments of | ||||||||||||||||||||||||||||
| 41 | type 'appledoublefile'. | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | It would be nice if we could write .MSG files too, but that will require | ||||||||||||||||||||||||||||
| 44 | quite a big rewrite. | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | Matijs van Zuijlen, C<matijs@matijs.net> | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | Copyright 2002--2020 by Matijs van Zuijlen | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | This module is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 55 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | =cut | ||||||||||||||||||||||||||||
| 58 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 59 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 60 | 9 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 61 | 9 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 62 | 9 | $VERSION = "0.920"; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 9 | ▶ | use Email::Simple; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 65 | 9 | ▶ | use Email::MIME::Creator; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 66 | 9 | ▶ | use Email::Outlook::Message::AddressInfo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 67 | 9 | ▶ | use Email::Outlook::Message::Attachment; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 68 | 9 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 69 | 9 | ▶ | use base 'Email::Outlook::Message::Base'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | our $skipheaders = { | ||||||||||||||||||||||||||||
| 72 | 9 | map { uc($_) => 1 } | |||||||||||||||||||||||||||
| 73 | "MIME-Version", | ||||||||||||||||||||||||||||
| 74 | "Content-Type", | ||||||||||||||||||||||||||||
| 75 | "Content-Transfer-Encoding", | ||||||||||||||||||||||||||||
| 76 | "X-Mailer", | ||||||||||||||||||||||||||||
| 77 | "X-Msgconvert", | ||||||||||||||||||||||||||||
| 78 | "X-MS-Tnef-Correlator", | ||||||||||||||||||||||||||||
| 79 | "X-MS-Has-Attach" | ||||||||||||||||||||||||||||
| 80 | }; | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 9 | our $MAP_SUBITEM_FILE = { | |||||||||||||||||||||||||||
| 83 | '1000' => "BODY_PLAIN", # Body | ||||||||||||||||||||||||||||
| 84 | '1009' => "BODY_RTF", # Compressed-RTF version of body | ||||||||||||||||||||||||||||
| 85 | '1013' => "BODY_HTML", # HTML Version of body | ||||||||||||||||||||||||||||
| 86 | '0037' => "SUBJECT", # Subject | ||||||||||||||||||||||||||||
| 87 | '0047' => "SUBMISSION_ID", # Seems to contain the date | ||||||||||||||||||||||||||||
| 88 | '007D' => "HEAD", # Full headers | ||||||||||||||||||||||||||||
| 89 | '0C1A' => "FROM", # From: Name | ||||||||||||||||||||||||||||
| 90 | '0C1E' => "FROM_ADDR_TYPE", # From: Address type | ||||||||||||||||||||||||||||
| 91 | '0C1F' => "FROM_ADDR", # From: Address | ||||||||||||||||||||||||||||
| 92 | '0E04' => "TO", # To: Names | ||||||||||||||||||||||||||||
| 93 | '0E03' => "CC", # Cc: Names | ||||||||||||||||||||||||||||
| 94 | '1035' => "MESSAGEID", # Message-Id | ||||||||||||||||||||||||||||
| 95 | '1039' => "REFERENCES", # References: Header | ||||||||||||||||||||||||||||
| 96 | '1042' => "INREPLYTO", # In reply to Message-Id | ||||||||||||||||||||||||||||
| 97 | '3007' => 'DATE2ND', # Creation Time | ||||||||||||||||||||||||||||
| 98 | '0039' => 'DATE1ST', # Outlook sent date | ||||||||||||||||||||||||||||
| 99 | '3FDE' => 'CODEPAGE', # Code page for text or html body | ||||||||||||||||||||||||||||
| 100 | }; | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | # Map codepage numbers to charset names. Codepages not listed here just get | ||||||||||||||||||||||||||||
| 103 | # 'CP' prepended, so 1252 -> 'CP1252'. | ||||||||||||||||||||||||||||
| 104 | 9 | our $MAP_CODEPAGE = { | |||||||||||||||||||||||||||
| 105 | 20127 => 'US-ASCII', | ||||||||||||||||||||||||||||
| 106 | 20866 => 'KOI8-R', | ||||||||||||||||||||||||||||
| 107 | 28591 => 'ISO-8859-1', | ||||||||||||||||||||||||||||
| 108 | 65001 => 'UTF-8', | ||||||||||||||||||||||||||||
| 109 | }; | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | # | ||||||||||||||||||||||||||||
| 112 | # Main body of module | ||||||||||||||||||||||||||||
| 113 | # | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | sub new { | ||||||||||||||||||||||||||||
| 116 | 7 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 117 | 7 | ▶ | my $file = shift or croak "File name is required parameter"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | 6 | my $verbose = shift; | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 6 | my $self = $class->_empty_new; | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 6 | $self->{EMBEDDED} = 0; | |||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 6 | my $msg = OLE::Storage_Lite->new($file); | |||||||||||||||||||||||||||
| 125 | 6 | my $pps = $msg->getPpsTree(1); | |||||||||||||||||||||||||||
| 126 | 6 | ▶ | $pps or croak "Parsing $file as OLE file failed"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | 6 | $self->_set_verbosity($verbose); | |||||||||||||||||||||||||||
| 128 | # TODO: Use separate object as parser? | ||||||||||||||||||||||||||||
| 129 | 6 | $self->_process_pps($pps); | |||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 6 | return $self; | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | sub _empty_new { | ||||||||||||||||||||||||||||
| 135 | 7 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
_empty_new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 7 | return bless { | |||||||||||||||||||||||||||
| 138 | ADDRESSES => [], ATTACHMENTS => [], FROM_ADDR_TYPE => "", | ||||||||||||||||||||||||||||
| 139 | VERBOSE => 0, EMBEDDED => 1 | ||||||||||||||||||||||||||||
| 140 | }, $class; | ||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | sub to_email_mime { | ||||||||||||||||||||||||||||
| 144 | 10 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
to_email_mime: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 10 | my $bodymime; | |||||||||||||||||||||||||||
| 147 | my $mime; | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 10 | my @parts; | |||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 10 | ▶ | if ($self->{BODY_PLAIN}) { push(@parts, $self->_create_mime_plain_body()); } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | 10 | ▶ | if ($self->{BODY_HTML}) { push(@parts, $self->_create_mime_html_body()); } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | 10 | ▶ | if ($self->{BODY_RTF}) { push(@parts, $self->_create_mime_rtf_body()); } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 10 | ▶ | if ((scalar @parts) > 1) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 156 | 7 | for (@parts) { $self->_clean_part_header($_) }; | |||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 7 | $bodymime = Email::MIME->create( | |||||||||||||||||||||||||||
| 159 | attributes => { | ||||||||||||||||||||||||||||
| 160 | content_type => "multipart/alternative", | ||||||||||||||||||||||||||||
| 161 | encoding => "8bit", | ||||||||||||||||||||||||||||
| 162 | }, | ||||||||||||||||||||||||||||
| 163 | parts => \@parts | ||||||||||||||||||||||||||||
| 164 | ); | ||||||||||||||||||||||||||||
| 165 | } elsif ((@parts) == 1) { | ||||||||||||||||||||||||||||
| 166 | 2 | $bodymime = $parts[0]; | |||||||||||||||||||||||||||
| 167 | } else { | ||||||||||||||||||||||||||||
| 168 | 1 | $bodymime = $self->_create_mime_plain_body(); | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 10 | ▶ | if (@{$self->{ATTACHMENTS}}>0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | 2 | $self->_clean_part_header($bodymime); | |||||||||||||||||||||||||||
| 173 | 2 | my $mult = Email::MIME->create( | |||||||||||||||||||||||||||
| 174 | attributes => { | ||||||||||||||||||||||||||||
| 175 | content_type => "multipart/mixed", | ||||||||||||||||||||||||||||
| 176 | encoding => "8bit", | ||||||||||||||||||||||||||||
| 177 | }, | ||||||||||||||||||||||||||||
| 178 | parts => [$bodymime], | ||||||||||||||||||||||||||||
| 179 | ); | ||||||||||||||||||||||||||||
| 180 | 2 | foreach my $att (@{$self->{ATTACHMENTS}}) { | |||||||||||||||||||||||||||
| 181 | 2 | $self->_SaveAttachment($mult, $att); | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | 2 | $mime = $mult; | |||||||||||||||||||||||||||
| 184 | } else { | ||||||||||||||||||||||||||||
| 185 | 8 | $mime = $bodymime; | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | #$mime->header_set('Date', undef); | ||||||||||||||||||||||||||||
| 189 | 10 | $self->_SetHeaderFields($mime); | |||||||||||||||||||||||||||
| 190 | 10 | $self->_copy_header_data($mime); | |||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 10 | return $mime; | |||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | # | ||||||||||||||||||||||||||||
| 196 | # Below are functions that walk the PPS tree. This is simply a tree walk. | ||||||||||||||||||||||||||||
| 197 | # It's not really recursive (except when an attachment contains a .msg | ||||||||||||||||||||||||||||
| 198 | # file), since the tree is shallow (max. 1 subdirectory deep). | ||||||||||||||||||||||||||||
| 199 | # | ||||||||||||||||||||||||||||
| 200 | # The structure is as follows: | ||||||||||||||||||||||||||||
| 201 | # | ||||||||||||||||||||||||||||
| 202 | # Root | ||||||||||||||||||||||||||||
| 203 | # Items with properties of the e-mail | ||||||||||||||||||||||||||||
| 204 | # Dirs containing addresses | ||||||||||||||||||||||||||||
| 205 | # Items with properties of the address | ||||||||||||||||||||||||||||
| 206 | # Dirs containing Attachments | ||||||||||||||||||||||||||||
| 207 | # Items with properties of the attachment (including its data) | ||||||||||||||||||||||||||||
| 208 | # Dir that is itself a .msg file (if the attachment is an email). | ||||||||||||||||||||||||||||
| 209 | # | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | sub _property_map { | ||||||||||||||||||||||||||||
| 212 | 6 | ▶ | return $MAP_SUBITEM_FILE; | ||||||||||||||||||||||||||
|
Subroutine
_property_map: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | # | ||||||||||||||||||||||||||||
| 216 | # Process a subdirectory. This is either an address or an attachment. | ||||||||||||||||||||||||||||
| 217 | # | ||||||||||||||||||||||||||||
| 218 | sub _process_subdirectory { | ||||||||||||||||||||||||||||
| 219 | 14 | ▶ | my ($self, $pps) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_process_subdirectory: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 14 | $self->_extract_ole_date($pps); | |||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 14 | my $name = $self->_get_pps_name($pps); | |||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 14 | ▶ | if ($name =~ '__recip_version1 0_ ') { # Address of one recipient | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 226 | 6 | $self->_process_address($pps); | |||||||||||||||||||||||||||
| 227 | } elsif ($name =~ '__attach_version1 0_ ') { # Attachment | ||||||||||||||||||||||||||||
| 228 | 2 | $self->_process_attachment($pps); | |||||||||||||||||||||||||||
| 229 | } else { | ||||||||||||||||||||||||||||
| 230 | 6 | $self->_warn_about_unknown_directory($pps); | |||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | 14 | return; | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | # | ||||||||||||||||||||||||||||
| 236 | # Process a subdirectory that contains an email address. | ||||||||||||||||||||||||||||
| 237 | # | ||||||||||||||||||||||||||||
| 238 | sub _process_address { | ||||||||||||||||||||||||||||
| 239 | 6 | ▶ | my ($self, $pps) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_process_address: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | my $addr_info = Email::Outlook::Message::AddressInfo->new($pps, | ||||||||||||||||||||||||||||
| 242 | 6 | $self->{VERBOSE}); | |||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 6 | push @{$self->{ADDRESSES}}, $addr_info; | |||||||||||||||||||||||||||
| 245 | 6 | return; | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | # | ||||||||||||||||||||||||||||
| 249 | # Process a subdirectory that contains an attachment. | ||||||||||||||||||||||||||||
| 250 | # | ||||||||||||||||||||||||||||
| 251 | sub _process_attachment { | ||||||||||||||||||||||||||||
| 252 | 2 | ▶ | my ($self, $pps) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_process_attachment: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | my $attachment = Email::Outlook::Message::Attachment->new($pps, | ||||||||||||||||||||||||||||
| 255 | 2 | $self->{VERBOSE}); | |||||||||||||||||||||||||||
| 256 | 2 | push @{$self->{ATTACHMENTS}}, $attachment; | |||||||||||||||||||||||||||
| 257 | 2 | return; | |||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | # | ||||||||||||||||||||||||||||
| 261 | # Header length of the property stream depends on whether the Message | ||||||||||||||||||||||||||||
| 262 | # object is embedded or not. | ||||||||||||||||||||||||||||
| 263 | # | ||||||||||||||||||||||||||||
| 264 | sub _property_stream_header_length { | ||||||||||||||||||||||||||||
| 265 | 6 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_property_stream_header_length: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||
| 266 | 6 | ▶ | return ($self->{EMBEDDED} ? 24 : 32) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | # | ||||||||||||||||||||||||||||
| 270 | # Helper functions | ||||||||||||||||||||||||||||
| 271 | # | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | # | ||||||||||||||||||||||||||||
| 274 | # Extract time stamp of this OLE item (this is in GMT) | ||||||||||||||||||||||||||||
| 275 | # | ||||||||||||||||||||||||||||
| 276 | sub _extract_ole_date { | ||||||||||||||||||||||||||||
| 277 | 14 | ▶ | my ($self, $pps) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_extract_ole_date: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||
| 278 | 14 | ▶ | unless (defined ($self->{OLEDATE})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 279 | # Make Date | ||||||||||||||||||||||||||||
| 280 | 7 | my $datearr; | |||||||||||||||||||||||||||
| 281 | 7 | $datearr = $pps->{Time2nd}; | |||||||||||||||||||||||||||
| 282 | 7 | ▶ | $datearr = $pps->{Time1st} unless $datearr and $datearr->[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$datearr and $datearr->[0]
MC/DC50%1/2
$datearr and $datearr->[0]
$datearr
$datearr->[0]
Truth table66%2/3
A and B
A= $datearrB= $datearr->[0]
| |||||||||||||||||||||||||||||
| 283 | 7 | ▶ | $self->{OLEDATE} = $self->_format_date($datearr) if $datearr and $datearr->[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$datearr and $datearr->[0]
MC/DC50%1/2
$datearr and $datearr->[0]
$datearr
$datearr->[0]
Truth table66%2/3
A and B
A= $datearrB= $datearr->[0]
| |||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||
| 285 | 14 | return; | |||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | # If we didn't get the date from the original header data, we may be able | ||||||||||||||||||||||||||||
| 289 | # to get it from the SUBMISSION_ID: | ||||||||||||||||||||||||||||
| 290 | # It seems to have the format of a semicolon-separated list of key=value | ||||||||||||||||||||||||||||
| 291 | # pairs. The key l has a value with the format: | ||||||||||||||||||||||||||||
| 292 | # <SERVER>-<DATETIME>Z-<NUMBER>, where DATETIME is the date and time (gmt) | ||||||||||||||||||||||||||||
| 293 | # in the format YYMMDDHHMMSS. | ||||||||||||||||||||||||||||
| 294 | sub _submission_id_date { | ||||||||||||||||||||||||||||
| 295 | 11 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_submission_id_date: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | 11 | ▶ | my $submission_id = $self->{SUBMISSION_ID} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 298 | 5 | ▶ | $submission_id =~ m/ l=.*- (\d\d) (\d\d) (\d\d) (\d\d) (\d\d) (\d\d) Z-.* /x | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 299 | or return; | ||||||||||||||||||||||||||||
| 300 | 5 | my $year = $1; | |||||||||||||||||||||||||||
| 301 | 5 | ▶ | $year += 100 if $year < 20; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 302 | 5 | return $self->_format_date([$6,$5,$4,$3,$2-1,$year]); | |||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | sub _SaveAttachment { | ||||||||||||||||||||||||||||
| 306 | 2 | ▶ | my ($self, $mime, $att) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_SaveAttachment: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | 2 | my $m = $att->to_email_mime; | |||||||||||||||||||||||||||
| 309 | 2 | $self->_clean_part_header($m); | |||||||||||||||||||||||||||
| 310 | 2 | $mime->parts_add([$m]); | |||||||||||||||||||||||||||
| 311 | 2 | return; | |||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | # Set header fields | ||||||||||||||||||||||||||||
| 315 | sub _AddHeaderField { | ||||||||||||||||||||||||||||
| 316 | 110 | ▶ | my ($self, $mime, $fieldname, $value) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_AddHeaderField: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | #my $oldvalue = $mime->header($fieldname); | ||||||||||||||||||||||||||||
| 319 | #return if $oldvalue; | ||||||||||||||||||||||||||||
| 320 | 110 | ▶ | $mime->header_set($fieldname, $value) if $value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 321 | 110 | return; | |||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | sub _Address { | ||||||||||||||||||||||||||||
| 325 | 10 | ▶ | my ($self, $tag) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_Address: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | 10 | ▶ | my $result = $self->{$tag} || ""; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{$tag} || ''
MC/DC100%1/1
$self->{$tag} || ''
$self->{$tag}
Truth table100%2/2
A
A= $self->{$tag}
| |||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | 10 | ▶ | my $address = $self->{$tag . "_ADDR"} || ""; | ||||||||||||||||||||||||||
|
Condition100%2/2
$$self{$tag . '_ADDR'} || ''
MC/DC100%1/1
$$self{$tag . '_ADDR'} || ''
$$self{$tag . '_ADDR'}
Truth table100%2/2
A
A= $$self{$tag . '_ADDR'}
| |||||||||||||||||||||||||||||
| 330 | 10 | ▶ | if ($address) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 331 | 3 | ▶ | $result .= " " if $result; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 332 | 3 | $result .= "<$address>"; | |||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | 10 | return $result; | |||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | # Find SMTP addresses for the given list of names | ||||||||||||||||||||||||||||
| 339 | sub _expand_address_list { | ||||||||||||||||||||||||||||
| 340 | 20 | ▶ | my ($self, $names) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_expand_address_list: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | 20 | ▶ | return "" unless defined $names; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | 11 | my @namelist = split / ; [ ]* /x, $names; | |||||||||||||||||||||||||||
| 345 | 11 | my @result; | |||||||||||||||||||||||||||
| 346 | 11 | name: foreach my $name (@namelist) { | |||||||||||||||||||||||||||
| 347 | 6 | my $addresstext = $self->_find_name_in_addresspool($name); | |||||||||||||||||||||||||||
| 348 | 6 | ▶ | if ($addresstext) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 349 | 5 | push @result, $addresstext; | |||||||||||||||||||||||||||
| 350 | } else { | ||||||||||||||||||||||||||||
| 351 | 1 | push @result, $name; | |||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||
| 354 | 11 | return join ", ", @result; | |||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | sub _find_name_in_addresspool { | ||||||||||||||||||||||||||||
| 358 | 6 | ▶ | my ($self, $name) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_find_name_in_addresspool: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | 6 | my $addresspool = $self->{ADDRESSES}; | |||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | 6 | foreach my $address (@{$addresspool}) { | |||||||||||||||||||||||||||
| 363 | 6 | ▶ | if ($name eq $address->name) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 364 | 5 | return $address->display_address; | |||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||
| 367 | 1 | return; | |||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | # TODO: Don't really want to need this! | ||||||||||||||||||||||||||||
| 371 | sub _clean_part_header { | ||||||||||||||||||||||||||||
| 372 | 18 | ▶ | my ($self, $part) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_clean_part_header: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 373 | 18 | $part->header_set('Date'); | |||||||||||||||||||||||||||
| 374 | 18 | ▶ | unless ($part->content_type =~ m{ ^ multipart / }x) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 375 | 15 | $part->header_set('MIME-Version') | |||||||||||||||||||||||||||
| 376 | }; | ||||||||||||||||||||||||||||
| 377 | 18 | return; | |||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | sub _body_character_set { | ||||||||||||||||||||||||||||
| 381 | 12 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_body_character_set: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 382 | 12 | return _codepage_to_charset($self->{CODEPAGE}); | |||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | sub _codepage_to_charset { | ||||||||||||||||||||||||||||
| 386 | 12 | ▶ | my $codepage = shift; | ||||||||||||||||||||||||||
|
Subroutine
_codepage_to_charset: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 387 | 12 | ▶ | if (defined $codepage) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 388 | 5 | ▶ | return $MAP_CODEPAGE->{$codepage} || "CP$codepage"; | ||||||||||||||||||||||||||
|
Condition50%1/2
$Email::Outlook::Message::MAP_CODEPAGE->{$codepage} || "CP$codepage"
MC/DC0%0/1
$Email::Outlook::Message::MAP_CODEPAGE->{$codepage} || "CP$codepage"
$Email::Outlook::Message::MAP_CODEPAGE->{$codepage}
Truth table50%1/2
A
A= $Email::Outlook::Message::MAP_CODEPAGE->{$codepage}
| |||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||
| 390 | 7 | return 'CP1252'; | |||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | sub _create_mime_plain_body { | ||||||||||||||||||||||||||||
| 394 | 9 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_create_mime_plain_body: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 395 | 9 | my $charset = $self->_body_character_set; | |||||||||||||||||||||||||||
| 396 | 9 | my $body_str = $self->{BODY_PLAIN}; | |||||||||||||||||||||||||||
| 397 | 9 | ▶ | if ($charset ne "UTF-8") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 398 | # In this case, the body is a string of octets and needs to be decoded. | ||||||||||||||||||||||||||||
| 399 | 6 | $body_str = Encode::decode($charset, $body_str); | |||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||
| 401 | 9 | return Email::MIME->create( | |||||||||||||||||||||||||||
| 402 | attributes => { | ||||||||||||||||||||||||||||
| 403 | content_type => "text/plain", | ||||||||||||||||||||||||||||
| 404 | charset => $charset, | ||||||||||||||||||||||||||||
| 405 | disposition => "inline", | ||||||||||||||||||||||||||||
| 406 | encoding => "8bit", | ||||||||||||||||||||||||||||
| 407 | }, | ||||||||||||||||||||||||||||
| 408 | body_str => $body_str | ||||||||||||||||||||||||||||
| 409 | ); | ||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | sub _create_mime_html_body { | ||||||||||||||||||||||||||||
| 413 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_create_mime_html_body: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 414 | return Email::MIME->create( | ||||||||||||||||||||||||||||
| 415 | attributes => { | ||||||||||||||||||||||||||||
| 416 | content_type => "text/html", | ||||||||||||||||||||||||||||
| 417 | charset => $self->_body_character_set, | ||||||||||||||||||||||||||||
| 418 | disposition => "inline", | ||||||||||||||||||||||||||||
| 419 | encoding => "8bit", | ||||||||||||||||||||||||||||
| 420 | }, | ||||||||||||||||||||||||||||
| 421 | body => $self->{BODY_HTML} | ||||||||||||||||||||||||||||
| 422 | 3 | ); | |||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | # Implementation based on the information in | ||||||||||||||||||||||||||||
| 426 | # http://www.freeutils.net/source/jtnef/rtfcompressed.jsp, | ||||||||||||||||||||||||||||
| 427 | # and the implementation in tnef version 1.4.5. | ||||||||||||||||||||||||||||
| 428 | 9 | my $MAGIC_COMPRESSED_RTF = 0x75465a4c; | |||||||||||||||||||||||||||
| 429 | 9 | my $MAGIC_UNCOMPRESSED_RTF = 0x414c454d; | |||||||||||||||||||||||||||
| 430 | 9 | my $BASE_BUFFER = | |||||||||||||||||||||||||||
| 431 | "{\\rtf1\\ansi\\mac\\deff0\\deftab720{\\fonttbl;}{\\f0\\fnil \\froman " | ||||||||||||||||||||||||||||
| 432 | . "\\fswiss \\fmodern \\fscript \\fdecor MS Sans SerifSymbolArial" | ||||||||||||||||||||||||||||
| 433 | . "Times New RomanCourier{\\colortbl\\red0\\green0\\blue0\n\r\\par " | ||||||||||||||||||||||||||||
| 434 | . "\\pard\\plain\\f0\\fs20\\b\\i\\u\\tab\\tx"; | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | sub _create_mime_rtf_body { | ||||||||||||||||||||||||||||
| 438 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_create_mime_rtf_body: called CC=8 SCAR=21.1
| |||||||||||||||||||||||||||||
| 439 | 5 | my $data = $self->{BODY_RTF}; | |||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | 5 | my ($size, $rawsize, $magic, $crc) = unpack "V4", substr $data, 0, 16; | |||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||
| 443 | 5 | my $buffer; | |||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | 5 | ▶ | if ($magic == $MAGIC_COMPRESSED_RTF) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 446 | 5 | $buffer = $BASE_BUFFER; | |||||||||||||||||||||||||||
| 447 | 5 | my $output_length = length($buffer) + $rawsize; | |||||||||||||||||||||||||||
| 448 | 5 | my @flags; | |||||||||||||||||||||||||||
| 449 | 5 | my $in = 16; | |||||||||||||||||||||||||||
| 450 | 5 | ▶ | while (length($buffer) < $output_length) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 451 | 456 | ▶ | if (@flags == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 452 | 60 | @flags = split "", unpack "b8", substr $data, $in++, 1; | |||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||
| 454 | 456 | my $flag = shift @flags; | |||||||||||||||||||||||||||
| 455 | 456 | ▶ | if ($flag eq "0") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 456 | 195 | $buffer .= substr $data, $in++, 1; | |||||||||||||||||||||||||||
| 457 | } else { | ||||||||||||||||||||||||||||
| 458 | 261 | my ($a, $b) = unpack "C2", substr $data, $in, 2; | |||||||||||||||||||||||||||
| 459 | 261 | my $offset = ($a << 4) | ($b >> 4); | |||||||||||||||||||||||||||
| 460 | 261 | my $length = ($b & 0xf) + 2; | |||||||||||||||||||||||||||
| 461 | 261 | my $buflen = length $buffer; | |||||||||||||||||||||||||||
| 462 | 261 | my $longoffset = $buflen - ($buflen % 4096) + $offset; | |||||||||||||||||||||||||||
| 463 | 261 | ▶ | if ($longoffset >= $buflen) { $longoffset -= 4096; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 464 | 261 | ▶ | while ($length > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 465 | 1364 | $buffer .= substr $buffer, $longoffset, 1; | |||||||||||||||||||||||||||
| 466 | 1364 | $length--; | |||||||||||||||||||||||||||
| 467 | 1364 | $longoffset++; | |||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||
| 469 | 261 | $in += 2; | |||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||
| 472 | 5 | $buffer = substr $buffer, length $BASE_BUFFER; | |||||||||||||||||||||||||||
| 473 | } elsif ($magic == $MAGIC_UNCOMPRESSED_RTF) { | ||||||||||||||||||||||||||||
| 474 | 0 | $buffer = substr $data, 16; | |||||||||||||||||||||||||||
| 475 | } else { | ||||||||||||||||||||||||||||
| 476 | 0 | carp "Incorrect magic number in RTF body.\n"; | |||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||
| 478 | 5 | return Email::MIME->create( | |||||||||||||||||||||||||||
| 479 | attributes => { | ||||||||||||||||||||||||||||
| 480 | content_type => "application/rtf", | ||||||||||||||||||||||||||||
| 481 | disposition => "inline", | ||||||||||||||||||||||||||||
| 482 | encoding => "base64", | ||||||||||||||||||||||||||||
| 483 | }, | ||||||||||||||||||||||||||||
| 484 | body => $buffer | ||||||||||||||||||||||||||||
| 485 | ); | ||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||
| 487 | # Copy original header data. | ||||||||||||||||||||||||||||
| 488 | # Note: This should contain the Date: header. | ||||||||||||||||||||||||||||
| 489 | sub _copy_header_data { | ||||||||||||||||||||||||||||
| 490 | 11 | ▶ | my ($self, $mime) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_copy_header_data: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||
| 492 | 11 | ▶ | defined $self->{HEAD} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | # The extra \n is needed for Email::Simple to pick up all headers. | ||||||||||||||||||||||||||||
| 495 | # This is a change in Email::Simple. | ||||||||||||||||||||||||||||
| 496 | 8 | my $parsed = Email::Simple->new($self->{HEAD} . "\n"); | |||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | 8 | foreach my $tag (grep { !$skipheaders->{uc $_}} $parsed->header_names) { | |||||||||||||||||||||||||||
| 499 | 74 | $mime->header_set($tag, $parsed->header($tag)); | |||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||
| 501 | 8 | return; | |||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||
| 504 | # Set header fields | ||||||||||||||||||||||||||||
| 505 | sub _SetHeaderFields { | ||||||||||||||||||||||||||||
| 506 | 10 | ▶ | my ($self, $mime) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_SetHeaderFields: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||
| 508 | 10 | $self->_AddHeaderField($mime, 'Subject', $self->{SUBJECT}); | |||||||||||||||||||||||||||
| 509 | 10 | $self->_AddHeaderField($mime, 'From', $self->_Address("FROM")); | |||||||||||||||||||||||||||
| 510 | #$self->_AddHeaderField($mime, 'Reply-To', $self->_Address("REPLYTO")); | ||||||||||||||||||||||||||||
| 511 | 10 | $self->_AddHeaderField($mime, 'To', $self->_expand_address_list($self->{TO})); | |||||||||||||||||||||||||||
| 512 | 10 | $self->_AddHeaderField($mime, 'Cc', $self->_expand_address_list($self->{CC})); | |||||||||||||||||||||||||||
| 513 | 10 | $self->_AddHeaderField($mime, 'Message-Id', $self->{MESSAGEID}); | |||||||||||||||||||||||||||
| 514 | 10 | $self->_AddHeaderField($mime, 'In-Reply-To', $self->{INREPLYTO}); | |||||||||||||||||||||||||||
| 515 | 10 | $self->_AddHeaderField($mime, 'References', $self->{REFERENCES}); | |||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | # Least preferred option to set the Date: header; this uses the date the | ||||||||||||||||||||||||||||
| 518 | # msg file was saved. | ||||||||||||||||||||||||||||
| 519 | 10 | $self->_AddHeaderField($mime, 'Date', $self->{OLEDATE}); | |||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | # Second preferred option: get it from the SUBMISSION_ID: | ||||||||||||||||||||||||||||
| 522 | 10 | $self->_AddHeaderField($mime, 'Date', $self->_submission_id_date()); | |||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||
| 524 | # Most preferred option from the property list | ||||||||||||||||||||||||||||
| 525 | 10 | $self->_AddHeaderField($mime, 'Date', $self->{DATE2ND}); | |||||||||||||||||||||||||||
| 526 | 10 | $self->_AddHeaderField($mime, 'Date', $self->{DATE1ST}); | |||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | # After this, we'll try getting the date from the original headers. | ||||||||||||||||||||||||||||
| 529 | 10 | return; | |||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||
| 532 | 9 | 1; | |||||||||||||||||||||||||||