N
Nic Harding
Hello,
I am trying to modify the 'From' field of outgoing emails. I am using
WinXP, programming with vb6, running Outlook 2003 and Redemption 3.4
..I have read some previous posts on this subject and also the
information on the Redemption site. When I send an email with a
modifyed 'From' address it comes back to me displayed as follows:
<Original Email Address> on behalf of <My New Email Address>
Why does'nt the 'From' field display the "New Email Address" ONLY,
with NO 'on behalf of' included?
Below is a snippet of my email code I have written:
Function SendEMail(sEmailTo As String, sSubject As String, sPath As
String)
Dim oOutlook As Outlook.Application
Dim oMAPI As Outlook.NameSpace
Dim oFolder As Outlook.MAPIFolder
Dim oMailItem As Outlook.MailItem
Dim oRecipient As Outlook.Recipient
Dim oFSO As Scripting.FileSystemObject
'Redemption
Dim oRED_MailItem As Redemption.SafeMailItem
Set oRED_MailItem = New Redemption.SafeMailItem
' Create an instance of an Outlook Application
Set oOutlook = New Outlook.Application
If Not oOutlook Is Nothing Then
' Get the MAPI NameSpace object
Set oMAPI = oOutlook.Session
If Not oMAPI Is Nothing Then
' Log in to the MAPI session
oMAPI.Logon , , True, True
' Create a pointer to the Outbox folder
Set oFolder = oMAPI.GetDefaultFolder(olFolderOutbox)
If Not oFolder Is Nothing Then
Set oMailItem = oFolder.Items.Add(olMailItem)
If Not oMailItem Is Nothing Then
With oMailItem
Set oFSO = New Scripting.FileSystemObject
.BodyFormat = olFormatHTML
.Subject = sSubject
.HTMLBody = oFSO.OpenTextFile(sPath).ReadAll()
.To = sEmailTo
'Redemption
Dim Tag As Variant
oRED_MailItem.Item = oMailItem
Tag =
oRED_MailItem.GetIDsFromNames("{00020386-0000-0000-C000-000000000046}",
"From")
Tag = Tag Or (&H1E) 'the type is PT_STRING8
oRED_MailItem.Fields(Tag) = "MyNewEmail
<[email protected]>"
oRED_MailItem.Subject = oRED_MailItem.Subject
'to trick Outlook into thinking that something has changed
oRED_MailItem.Save
oRED_MailItem.Send
'Programatically click send/reveive
Dim oCtl As Office.CommandBarControl
Dim oCB As Office.CommandBar
Set oCtl =
Application.ActiveExplorer.CommandBars.FindControl(1, 7095)
oCtl.Execute
Set oCtl = Nothing
Set oCB = Nothing
Set oFSO = Nothing
Set oMailItem = Nothing
End With
End If
Set oFolder = Nothing ...........
Thanks in advance for any help.
Nic Harding.
I am trying to modify the 'From' field of outgoing emails. I am using
WinXP, programming with vb6, running Outlook 2003 and Redemption 3.4
..I have read some previous posts on this subject and also the
information on the Redemption site. When I send an email with a
modifyed 'From' address it comes back to me displayed as follows:
<Original Email Address> on behalf of <My New Email Address>
Why does'nt the 'From' field display the "New Email Address" ONLY,
with NO 'on behalf of' included?
Below is a snippet of my email code I have written:
Function SendEMail(sEmailTo As String, sSubject As String, sPath As
String)
Dim oOutlook As Outlook.Application
Dim oMAPI As Outlook.NameSpace
Dim oFolder As Outlook.MAPIFolder
Dim oMailItem As Outlook.MailItem
Dim oRecipient As Outlook.Recipient
Dim oFSO As Scripting.FileSystemObject
'Redemption
Dim oRED_MailItem As Redemption.SafeMailItem
Set oRED_MailItem = New Redemption.SafeMailItem
' Create an instance of an Outlook Application
Set oOutlook = New Outlook.Application
If Not oOutlook Is Nothing Then
' Get the MAPI NameSpace object
Set oMAPI = oOutlook.Session
If Not oMAPI Is Nothing Then
' Log in to the MAPI session
oMAPI.Logon , , True, True
' Create a pointer to the Outbox folder
Set oFolder = oMAPI.GetDefaultFolder(olFolderOutbox)
If Not oFolder Is Nothing Then
Set oMailItem = oFolder.Items.Add(olMailItem)
If Not oMailItem Is Nothing Then
With oMailItem
Set oFSO = New Scripting.FileSystemObject
.BodyFormat = olFormatHTML
.Subject = sSubject
.HTMLBody = oFSO.OpenTextFile(sPath).ReadAll()
.To = sEmailTo
'Redemption
Dim Tag As Variant
oRED_MailItem.Item = oMailItem
Tag =
oRED_MailItem.GetIDsFromNames("{00020386-0000-0000-C000-000000000046}",
"From")
Tag = Tag Or (&H1E) 'the type is PT_STRING8
oRED_MailItem.Fields(Tag) = "MyNewEmail
<[email protected]>"
oRED_MailItem.Subject = oRED_MailItem.Subject
'to trick Outlook into thinking that something has changed
oRED_MailItem.Save
oRED_MailItem.Send
'Programatically click send/reveive
Dim oCtl As Office.CommandBarControl
Dim oCB As Office.CommandBar
Set oCtl =
Application.ActiveExplorer.CommandBars.FindControl(1, 7095)
oCtl.Execute
Set oCtl = Nothing
Set oCB = Nothing
Set oFSO = Nothing
Set oMailItem = Nothing
End With
End If
Set oFolder = Nothing ...........
Thanks in advance for any help.
Nic Harding.