Sub createEmail()
Dim olApp As Outlook.Application
Set olApp = New Outlook.Application
Dim olMail As MailItem
Set olMail = Outlook.CreateItem(olMailItem)
With olMail
.To = "glasswalk3r@yahoo.com.br"
.Subject = "Testing a customized header"
.BodyFormat = olFormatPlain
.body = "Hello there!" & vbCrLf _
& "This is a VBA POC (with Redemption!) generated email and should have a " _
& "nice customized header (X-Reported-Via)." & vbCrLf _
& "My best regards," & vbCrLf & "Alceu"
.Importance = olImportanceHigh
.ReadReceiptRequested = True
End With
Dim sItem As Object
Set sItem = CreateObject("Redemption.SafeMailItem")
sItem.item = olMail
Tag = sItem.GetIDsFromNames("{00020386-0000-0000-C000-000000000046}", "X-Reported-Via")
Tag = Tag Or &H1E 'the type is PT_STRING8
With sItem
.Fields(Tag) = "Test::Reporter Test::Reporter::Transport::Outlook"
.Subject = sItem.Subject 'to trick Outlook into thinking that something has changed
.Send
End With
Set olMail = Nothing
End Sub
####
my $tag = Win32::OLE::Variant->new( VT_R8, $self->{message}->GetIDsFromNames( '{00020386-0000-0000-C000-000000000046}', $name ));
# converting the numeric value to binary and back to decimal
my $pt_string8 = unpack( "B*", pack( "N", 0x0000001E ) );
my $tag_bin = unpack( "B*", pack( "N", $tag->Value() ) );
my $test = $tag_bin | $pt_string8;
$self->{message}->Fields->Put( oct("0b$test"), $value);
####
$self->{message}->Fields( oct("0b$test"), $value);
####
my $array = Win32::OLE::Variant->new( VT_BSTR | VT_ARRAY, oct("0b$test") );
####
use Win32::OLE::Variant;
my $tag = Win32::OLE::Variant->new( VT_R8,
$self->{message}
->GetIDsFromNames( '{00020386-0000-0000-C000-000000000046}', $name )
);
# When using GetIDsFromNames you must OR the result you get back with the type of property tag,
# in this case PT_STRING8.
# PT_STRING8 == 0x0000001E
# in binary
my $pt_string8 = unpack( "B*", pack( "N", 0x0000001E ) );
my $tag_bin = unpack( "B*", pack( "N", $tag->Value() ) );
my $test = $tag_bin | $pt_string8;
$test = oct("0b$test");
#$self->{message}->{Fields} = $array->Value();
#$self->{message}->{Fields}->[$test] = $value;
$self->{message}->LetProperty('Fields', $test, $value);