Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook - Change from...

Status
Not open for further replies.

Namlop

Programmer
Nov 8, 2002
36
0
0
NL
Hi,

I've got a question.
What do i need to change in my code so that when my program sends a mail, the recipient will see my programs name by From instead of my name

This is my code:
Sub SendMail(strEmail As String, intResultaat As Integer)
Dim olApp As New Outlook.Application
Dim olNs As Outlook.NameSpace
Dim olMail As Outlook.MailItem

On Error GoTo ErrHandler
Set olApp = CreateObject("Outlook.Application")
Set olNs = olApp.GetNamespace("MAPI")
olNs.Logon
Set olMail = olApp.CreateItem(olMailItem)


olMail.To = strEmail
olMail.Subject = "Diagnostic & Solution Tool Report"
olMail.Body = "Hallo, " & vbCrLf & "Op dit moment levert de door u opgegeven query " & vbCrLf & CStr(intResultaat) & " resultaten op." & vbCrLf & vbCrLf & "Vriendelijke Groeten."
olMail.Send

olNs.Logoff
' olApp.Quit
Set olNs = Nothing
Set olMail = Nothing
Set olApp = Nothing

Exit Sub
ErrHandler:
.....

I love work.
I can just sit and look at it for hours.
 
ive never used outlook objects before but i imagine its something along the lines of...

olMail.SenderName = App.Productname

or maybe

olMail.SentOnBehalfOfName=app.productname

good luck! If somethings hard to do, its not worth doing - Homer Simpson
 
Unfortunatly not.

.SenderName is read-only
and .SentOnBehalfOfName can only be used
in combination with the adressbook.
But since i have no access to the adressbook
that's not an option either. I love work.
I can just sit and look at it for hours.
 
I don't think it can be done by automating Outlook or using the CDO library. To use SentOnBehalfOfName requires that sender to have a mailbox on Exchange server and have granted delegate permissions to all mailboxes that will create the e-mails.

CDONTS or CDO for W2000 can send SMTP mail and there are third party Active X controls available too. They don't require a MAPI mail client to be present and normally let you set the sender name to anything. For a 3rd party example, have a look at:


Paul Bent
Northwind IT Systems
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top