Save outlook message as eml incomplete (body missing,attachments not opening,...) - outlook-redemption

I try to save outlook mails within an SQL-BLOB-Field as eml (or raw) content.
I have a form within MS Access to get the mails from outlook code:
Dim objitem As Outlook.MailItem
Set objOutlook = New Outlook.Application
Set objMapiFolder = objOutlook.Session.Folders("USER").Folders("Posteingang")
Dim inboundemail As ADODB.Recordset
Set inboundemail = New ADODB.Recordset
inboundemail.Open "Inbound_EMail_Buffer", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Set MailList = objMapiFolder.Items
Dim senderMail As String
Dim ReceiverMail As String
FillAddress
Dim SAfeMailItem
Set SAfeMailItem = CreateObject("Redemption.SafeMailItem")
For Each objitem In MailList
If objitem.Class = olMail Then
With objitem
inboundemail.AddNew
Select Case .SenderEmailType
Case "SMTP"
senderMail = .SenderEmailAddress
Case "EX"
senderMail = FindAddress(.SenderEmailAddress)
End Select
inboundemail!From = Left(Chr(34) & .SenderName & Chr(34) & " <" & senderMail & ">", 80)
inboundemail!To = .To
inboundemail!CC = .CC
inboundemail!Subject = Left(.Subject, 80)
inboundemail!DateReceived = .ReceivedTime
inboundemail!uid = .EntryId
SAfeMailItem.Item = objitem
x = SAfeMailItem.SaveAs("c:\temp\" & .EntryId & ".eml", olRFC822)
inboundemail!Size = .Size
inboundemail.Update
End With
End If
Next objitem
Me.ctlDocuments.Requery
Set objitem = Nothing
Set objOutlook = Nothing
Unfortunately the original Mail isn't saved complete
this is the mail in outlook
this is the saved .eml mail
saved eml after 5.23

Related

ADO adLockBatchOptimistic allows updates on modified records

I'm begging for help, since I'm too stupid.
What I do:
Open connection to Access DB
Download Table to a Recordset
Disconnect the RecordSet
Update a record
Update the same record in DB (by another user)
Connect RecordSet back to DB
UpdateBatch affected record
Yesterday it was throwing an error that the record has been modified in the meantime.
Today it's updating the record without any issues.
I would bet my arm I haven't changed anything...
I open the recordset with following settings (first set them, then open):
.CursorLocation = adUseClient
.LockType = adLockBatchOptimistic
I beg everyone for help
Example Code:
Dim DB_FOLDER_PATH As String
Dim DB_FILE_NAME As String
Dim DB_FILE_PATH As String
Dim CONNECTION As ADODB.CONNECTION
Dim CONNECTION_STRING As String
Dim QUERY_STRING As String
Dim tmp_RS As ADODB.Recordset
Dim tmp_RS2 As ADODB.Recordset
DB_FOLDER_PATH = "\\XXXXX\userdata\XXXXX\home\Documents\Data Base\"
DB_FILE_NAME = "TEST"
DB_FILE_PATH = DB_FOLDER_PATH & DB_FILE_NAME & ".accdb"
Set CONNECTION = New ADODB.CONNECTION
CONNECTION_STRING = "Provider=Microsoft.ACE.OLEDB.12.0" & ";" & "Data Source=" & DB_FILE_PATH & ";" & "Persist Security Info=False"
CONNECTION.Open CONNECTION_STRING
QUERY_STRING = "SELECT" & " " & "*" & " FROM [" & "DATA" & "]" & ";"
Set tmp_RS = New ADODB.Recordset
With tmp_RS
.CursorLocation = adUseClient
.LockType = adLockBatchOptimistic
.Open QUERY_STRING, CONNECTION
.ActiveConnection = Nothing
End With
Set tmp_RS2 = New ADODB.Recordset
With tmp_RS2
.CursorLocation = adUseClient
.LockType = adLockBatchOptimistic
.Open QUERY_STRING, CONNECTION
.ActiveConnection = Nothing
End With
With tmp_RS
.Fields("FIELD_LONG_TEXT_PLAIN").Value = "ABC"
.Update
.ActiveConnection = CONNECTION
.UpdateBatch
End With
With tmp_RS2
.Fields("FIELD_LONG_TEXT_PLAIN").Value = "ZXC"
.Update
.ActiveConnection = CONNECTION
.UpdateBatch
End With
Best Regards,
Michal

Create a plain text message with Exchange 2013

I am trying to send a plain text message every time I create a message it changes to HTML format.
I am using PowerShell v5 with CDO 1.2.1 with Redemption v5.19 and connecting to Exchange 2013.
I am creating an IPM.Note and setting the bodyformat to 1 (plain text), however as soon as I add any text to the body the bodyformat value changes to 2 (HTML). Once bodyformat is set to 2 I cannot change the value back.
$rs = New-Object -ComObject "Redemption.RDOSession"
$rsOutbox = $rs.GetDefaultFolder(4)
$msg = $rsOutbox.items.add("IPM.Note")
$msg.BodyFormat = 1
$msg.body = "Test"
You can try to set the RTFBody instead to a string that explicitly specifies plain text body:
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set folder = Session.GetDefaultFolder(4)
set Msg = folder.Items.Add
Msg.To = "user#example.com.com"
Msg.Subject = "testing body format"
Msg.RTFBody = "{\rtf1\ansi\ansicpg1252\fromtext \fbidis \deff0{\fonttbl " & _
"{\f0\fswiss Arial;}" & _
"{\f1\fmodern Courier New;}" & _
"{\f2\fnil\fcharset2 Symbol;}" & _
"{\f3\fmodern\fcharset0 Courier New;}}" & _
"{\colortbl\red0\green0\blue0;\red0\green0\blue255;}" & _
"\uc1\pard\plain\deftab360 \f0\fs20 Test \par" & _
"}"
Msg.BodyFormat = 1
Msg.Save

Match Data In Two Files Then Email Each Person

For simplicity, file1.txt is a log file for which I extract logonIds into an array. File2.txt contains rows of logonID,emailAddress,other,needless,data
I need to take all of the logonIDs read into my array from file1 and extract their email addresses from file2. Once I have this information, I can then send each person in file1 an email. Can't just use file2.txt because it contains users who should not receive an email.
I wrote vbscript that extracts logonIDs from file1.txt into array and pulls logonID and email from file2.txt
inFile1 = "C:\Scripts\testvbs\wscreatestatus.txt"
inFile2 = "C:\Scripts\testvbs\WSBatchCreateBuildsList.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objInFile1 = objFSO.OpenTextFile(inFile1, ForReading)
Set objInFile2 = objFSO.OpenTextFile(inFile2, ForReading)
'Creates Array of all DomainIDs for successful deployments
Do Until objInFile1.AtEndOfStream
strNextLine = objInFile1.Readline
arrLogons = Split(strNextLine , vbTab)
If arrLogons(0) = "DEPLOYSUCCESS" Then
arrUserIDList = arrUserIDList & arrLogons(5) & vbCrLf
End If
Loop
Do Until objInFile2.AtEndOfStream
strNextLine = objInFile2.Readline
arrAddressList = Split(strNextLine , ",")
arrMailList = arrMailList & arrAddressList(0) & vbTab & arrAddressList(1) & vbCrLf
Loop
What I need to do next is take my list of user IDs "arrUserIDList", and extract their email address from arrMailList. With this information I can send each user in file1.txt (wscreatestatus.txt) an email.
Thanks!
From the way you construct your arrMailList, I presume you want the selected LogonID's and corresponding email addresses output to a new Tab delimited text file.
If that is the case, I recommend using ArrayList objects to store the values in. ArrayLists have an easy to use Add method and for testing if an item is in an ArrayList, there is the Contains method.
In Code:
Option Explicit
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Dim inFile1, inFile2, outFile, objFSO, objInFile, objOutFile
Dim strNextLine, fields, arrUserIDList, arrMailList
inFile1 = "C:\Scripts\testvbs\wscreatestatus.txt"
inFile2 = "C:\Scripts\testvbs\WSBatchCreateBuildsList.txt"
outFile = "C:\Scripts\testvbs\WSEmailDeploySuccess.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objInFile = objFSO.OpenTextFile(inFile1, ForReading)
'Create an ArrayList of all DomainIDs for successful deployments
Set arrUserIDList = CreateObject( "System.Collections.ArrayList" )
Do Until objInFile.AtEndOfStream
strNextLine = objInFile.Readline
fields = Split(strNextLine , vbTab)
If fields(0) = "DEPLOYSUCCESS" Then
arrUserIDList.Add fields(5)
End If
Loop
'close the first input file
objInFile.Close
'Now read the second file and read the logonID's from it
Set objInFile = objFSO.OpenTextFile(inFile2, ForReading)
'Create an ArrayList of all LogonID's, a TAB character and the EmailAddress
Set arrMailList = CreateObject( "System.Collections.ArrayList" )
Do Until objInFile.AtEndOfStream
strNextLine = objInFile.Readline
fields = Split(strNextLine , ",")
If arrUserIDList.Contains(fields(0)) Then
' store the values in arrMailList as TAB separated values
arrMailList.Add fields(0) & vbTab & fields(1)
End If
Loop
'close the file and destroy the object
objInFile.Close
Set objInFile = Nothing
Set objOutFile = objFSO.OpenTextFile(outFile, ForWriting, True)
For Each strNextLine In arrMailList
objOutFile.WriteLine(strNextLine)
Next
'close the file and destroy the object
objOutFile.Close
Set objOutFile = Nothing
'clean up the other objects
Set objFSO = Nothing
Set arrUserIDList = Nothing
Set arrMailList = Nothing
Hope that helps
This is how I solved my problem, but I think Theo took a better approach.
Const ForReading = 1
Const ForWriting = 2
Dim inFile1, inFile2, strNextLine, arrServiceList, arrUserList
Dim arrUserDeployList, strLine, arrList, outFile, strItem1, strItem2
inFile1 = Wscript.Arguments.Item(0) 'wscreatestatus.txt file (tab delimited)
inFile2 = Wscript.Arguments.Item(1) 'WSBatchCreateBuildsList.txt (comma delimited)
outFile = Wscript.Arguments.Item(2) 'SuccessWSMailList###.txt (for Welcome emails)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objInFile1 = objFSO.OpenTextFile(inFile1, ForReading)
Set objInFile2 = objFSO.OpenTextFile(inFile2, ForReading)
Set objOutFile = objFSO.CreateTextFile(outFile, ForWriting, True)
'Extracts Logon ID's for successfull deployments into an Array
'#================================================================
i = 0
Do Until objInFile1.AtEndOfStream
ReDim Preserve arrUsers(i)
strNextLine = objInFile1.Readline
arrLogons = Split(strNextLine , vbTab)
If arrLogons(0) = "PENDINGREQUESTS" Then
arrUsers(i) = arrLogons(5)
i = i + 1
End If
Loop
'Extracts success deploy email addresses and writes to file
'#================================================================
Do Until objInFile2.AtEndOfStream
ReDim Preserve arrMailList(i)
strNextLine = objInFile2.Readline
arrAddressList = Split(strNextLine , ",")
strItem1 = arrAddressList(0)
strItem2 = arrAddressList(1)
For Each strArrayEntry In arrUsers
If strArrayEntry = strItem1 Then
objOutFile.WriteLine strItem1 & "," & strItem2
End If
Next
i = i + 1
Loop
objOutFile.Close
objInFile1.Close
objInFile2.Close

HPQC - RecordSet Not Displaying All Data

I am using HP (Microfocus) Quality Center 12.5 and designed a button using the toolbar in Workflow.
The following code pulls the first value from the RecordSet but not all values. How do I pull all values from the RecordSet and display it?
Sub searchDefects()
On Error Resume Next
Dim a
a = InputBox("Enter search query")
set TD1 = TDConnection
set com1 = TD1.command
com1.CommandText = "Select BG_BUG_ID FROM BUG WHERE BG_DESCRIPTION LIKE '%"
&a &"%'"
set rec1 = com1.Execute
Dim i
DIM msg
msg = ""
rec1.First
For i = 0 to rec1.RecordCount
msg = msg & "," & rec1.FieldValue(i) & ","
rec1.Next()
Next
MsgBox msg
On Error GoTo 0
End Sub
I found a solution after trial and error but still don't know the reason behind the root cause and how it is solving it. Any feedback is appreciated.
Sub SearchDefectsDescription()
On Error Resume Next
Dim a
a = InputBox("Enter search query for Description field")
set TD1 = TDConnection
set com1 = TD1.command
com1.CommandText = "Select BG_BUG_ID FROM BUG WHERE BG_DESCRIPTION LIKE '%" &a &"%'"
set rec1 = com1.Execute
Dim i
DIM msg
msg = "Bug ID" & vbnewline
rec1.First
If a = vbCancel Then
MsgBox "Search is cancelled"
Exit Sub
ElseIf Len(a) = 0 Then
MsgBox "Search input is empty, plesea try again."
Exit Sub
Else
For i = 0 to rec1.RecordCount
msg = msg & rec1.FieldValue(0) & rec1.FieldValue(1) & " "
rec1.Next()
Next
End If
MsgBox msg
On Error GoTo 0
End Sub

VB.net getting tag info into mp3 files

How can I get internal info about sound files using a MediaElement?
I know how to get the duration of a song file with NaturalDuration property but I want to get access to Author and others tag that many mp3 files include into themselves. Is there some way to do this using just MediaElement? I know how to do it but only with WMP and I really need to do it just with a MediaElement because my application is a UWP application.
Thanks!!!
Ok, late and may be not so elegant but this was my solution for getting duration of a mp3 file. I used MusicProperties Class. With this class you get access for any music tag information into the file.
Public Function infoMP3(elfichero As String) As String
Dim salida As String = ""
Dim miTask = Task.Run(Async Function() As Task(Of String)
Dim musicFile As StorageFile = Await StorageFile.GetFileFromPathAsync(elfichero)
Dim FileProperties As StorageItemContentProperties = musicFile.Properties
Dim musicFileProperties As MusicProperties = Await FileProperties.GetMusicPropertiesAsync()
Dim tiempo = musicFileProperties.Duration
Dim horas As String
If tiempo.Hours < 10 Then
horas = "0" & tiempo.Hours.ToString
Else
horas = tiempo.Hours.ToString
End If
Dim minutos As String
If tiempo.Minutes < 10 Then
minutos = "0" & tiempo.Minutes.ToString
Else
minutos = tiempo.Minutes.ToString
End If
Dim segundos As String
If tiempo.Seconds < 10 Then
segundos = "0" & tiempo.Seconds.ToString
Else
segundos = tiempo.Seconds.ToString
End If
Dim autor = musicFileProperties.Artist
Dim titulo = musicFileProperties.Title
Dim presalida As String = "[" & horas & ":" & minutos & ":" & segundos & "];[" & titulo & "];[" & autor & "] " & elfichero
Return presalida
End Function)
miTask.Wait()
salida = miTask.Result
Return salida
End Function
To get access to the files later on Windows 10, you have to save permission for the files and/or folders. Do this when you select them.
... Dim listToken = Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(rutaS) ...
where rutaS is an SotorageFolder object.

Resources