Send message from Outlook 2003 by non default e-mail account

  • Thread starter Thread starter Diplodok
  • Start date Start date
D

Diplodok

Hi all. I use VBA macro for autoresponding to customer registration.
It works as well, but I want to send those autoresponers by specified
e-mail account, not by default one. It is possible, when I use custom
form and ItemAdd method. However, that method is not good for me,
because Outlook 2003 add attachment winmail.dat to all messages I
send.
So, question is:
1. How to send messages using CreateItem(olMailItem) method by non
default e-mail.account?
2. OR how to prevent adding attachment winmail.dat to message, when
using custom form

Than you
Andrey Kuzmin
 
Winmail.dat should only be sent if the item is sent in RTF format. Is that
the case? Change that and that problem should go away.

You can send from a specific account by using the SentOnBehalfOfName
property, but that's somewhat limited.

With Outlook 2007 or later you can use the Accounts collection and the
MailItem.SendUsingAccount, but that's only 2007 or later.

I'd probably recommend using Redemption (www.dimastr.com/redemption) and its
RDOMail.Account property to set the sending account.
 
Thank you for reply, Ken.
"Winmail.dat should only be sent if the item is sent in RTF format. Is that
the case? Change that and that problem should go away."

It is not works. I set message.Body to plain, but there is winmail.dat
as attachment
SentOnBehalfOfName - Outlook says that property is readonly:-(
See my code below, please. May be I did some mistakes?
This put in the ThisOutlookSession class, Handler is initialized at
outlook startup
----------------------------------------------------------
Public Sub myOlItems_ItemAdd(ByVal Item As Object)
Dim nmail As Outlook.MailItem
If Item.Subject = "New registration OnLine 2010" Then
If Item.SenderEmailAddress = "(e-mail address removed)" Then
a = GetInfo(Item.Body, "e-mail") ' Get address from
message body
fn = GetInfo(Item.Body, "first name")
mn = GetInfo(Item.Body, "middle name")
ln = GetInfo(Item.Body, "last name")
Set nmail = Application.CreateItem(olMailItem)
nmail.To = a
nmail.Subject = "Conference Registration
AutoResponder. Do not reply."
nmail.BodyFormat = olFormatPlain
nmail.Body = "Dear """ & fn & " " & mn & " " & ln &
"""!" & vbCrLf & _
"Your Registration Form was received by
Organizational Committee on " & Now() & vbCrLf & _
"If we'll accept your registration, the
conference document package" & vbCrLf & _
"will send to your e-mail address """ & a
& """ within 2-3 days. " & vbCrLf & _
"Otherwise we will contact you by email."
& vbCrLf & vbCrLf & _
"------------------------------------" &
vbCrLf & "Organizational Committee" & vbCrLf
nmail.OriginatorDeliveryReportRequested = True
nmail.ReadReceiptRequested = True
Set nmail.SaveSentMessageFolder =
Application.GetNamespace("MAPI").Folders("Inbox").Folders("test")
nmail.Send
End If
End If
End Sub
 
If you look in the object browser and its help you will see that
SentOnBehalfOfName is read/write, not readonly.

You need to see what your custom form is set for, what the sending
properties of the recipient are, and what Internet sending settings you have
both in Outlook and if you are using Exchange what the mailbox settings are
for sending over the Internet.




Thank you for reply, Ken.
"Winmail.dat should only be sent if the item is sent in RTF format. Is
that
the case? Change that and that problem should go away."

It is not works. I set message.Body to plain, but there is winmail.dat
as attachment
SentOnBehalfOfName - Outlook says that property is readonly:-(
See my code below, please. May be I did some mistakes?
This put in the ThisOutlookSession class, Handler is initialized at
outlook startup
----------------------------------------------------------
Public Sub myOlItems_ItemAdd(ByVal Item As Object)
Dim nmail As Outlook.MailItem
If Item.Subject = "New registration OnLine 2010" Then
If Item.SenderEmailAddress = "(e-mail address removed)" Then
a = GetInfo(Item.Body, "e-mail") ' Get address from
message body
fn = GetInfo(Item.Body, "first name")
mn = GetInfo(Item.Body, "middle name")
ln = GetInfo(Item.Body, "last name")
Set nmail = Application.CreateItem(olMailItem)
nmail.To = a
nmail.Subject = "Conference Registration
AutoResponder. Do not reply."
nmail.BodyFormat = olFormatPlain
nmail.Body = "Dear """ & fn & " " & mn & " " & ln &
"""!" & vbCrLf & _
"Your Registration Form was received by
Organizational Committee on " & Now() & vbCrLf & _
"If we'll accept your registration, the
conference document package" & vbCrLf & _
"will send to your e-mail address """ & a
& """ within 2-3 days. " & vbCrLf & _
"Otherwise we will contact you by email."
& vbCrLf & vbCrLf & _
"------------------------------------" &
vbCrLf & "Organizational Committee" & vbCrLf
nmail.OriginatorDeliveryReportRequested = True
nmail.ReadReceiptRequested = True
Set nmail.SaveSentMessageFolder =
Application.GetNamespace("MAPI").Folders("Inbox").Folders("test")
nmail.Send
End If
End If
End Sub
----------------------------------------------------------
 
Back
Top