Solved

Sending mail through Outlook

Posted on 2002-03-23
10
147 Views
Last Modified: 2010-05-02
I use "Microsoft OutLook 9.0 Object Library" to send mails from my application. And I am facing the following problems.
A) In a few cases, I am required to change the from address of the mail that I send. Can this be done?
B) I need to set a hidden variable in the mail so that I will be able to browse the inbox and match the replies that I get for tha mails that I send. How do I do it?

Can anyone please help.

Sriram.
0
Comment
Question by:sriram_in
  • 5
  • 4
10 Comments
 
LVL 12

Expert Comment

by:roverm
ID: 6891414
Hi Sriram,

Are you sending the emails via an Exchange Server ?
If so: then you can change the from addy by direct accessing the pickup folder for exchange.

AFAIK it is not possible to send webmail via Outlook 9 as from another "from".

If you want to send emails via an SMTP server which allows different "from"s then you can use this:

http://www.freevbcode.com/ShowCode.Asp?ID=109

For the second part:
I don't know how to do that, I would try to read the subject.

Just one note:
These kind of questions can be seen as trying to build a spam application. I do think that you are sincere here.

D'Mzzl!
RoverM
0
 

Author Comment

by:sriram_in
ID: 6891853
Hi RoverM,

You can be assured that it is not a spamming software. This application will be deployed as an internal reporting tool.

I am sending mails through an Exchange Server. Using an SMTP server is ruled out. Can you clarify further about directly accessing the pickup folder?

Thanks,
Sriram.
0
 

Author Comment

by:sriram_in
ID: 6891856
If changing the from address is impossible, can you specify how to set the "Send replies to" address?
Thanks,
Sriram.
0
 
LVL 12

Expert Comment

by:roverm
ID: 6892010
Ok, but got the example at work, so please be patient, will post it monday. (CET+1)

D'Mzzl!
RoverM
0
 

Author Comment

by:sriram_in
ID: 6892015
Hi RoverM,
I had solved the first part. I used "SentOnBehalfOfName" property in the mailItem object to change the from address. The only problem with this method was that I needed to have access rights for the mailbox that I try to send from.

But, I still have the second issue pending.

Thanks,
Sriram.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 12

Expert Comment

by:roverm
ID: 6892019
The SentOnBehalfOfName is not the same as altering the from. In the example I will give you, you don't need access rights. The only thing you need is access to that pickup folder (NT user rights).

I will look into the second part tho.

D'Mzzl!
RoverM
0
 
LVL 12

Accepted Solution

by:
roverm earned 100 total points
ID: 6902310
k, here's the example:

  'Parse form variables in mail text
  Dim objMail 'SMTPsvg.Mailer

  'Send mail
  Set objMail = CreateObject("SMTPsvg.Mailer")
 
  objMail.FromName = "SenderName"
  objMail.FromAddress = "SenderName@mysmtpserver.com"
  strMailHost = "HOSTNAME"
  objMail.RemoteHost = strMailHost
  objMail.AddRecipient "Someone", strReceipent
  objMail.ReturnReceipt = False
  objMail.ConfirmRead = False
  objMail.Subject = strSubject  
  objMail.BodyText = strBodyText
  objMail.AddAttachment strAttach

  If Not objMail.SendMail Then
     MsgBox "Error: " & objMail.Response
  End If
   
  Set objMail = Nothing

In this example the strMailHost is the hostname of your exchange server.

D'Mzzl!
RoverM
0
 

Author Comment

by:sriram_in
ID: 6902365
Hi RoverM,
I will need to use "Outlook.Application" to make the application. That was the challenge given to me.

Which library does "SMTPsvg.Mailer" belong? Also, if "SMTPsvg.Mailer" uses direct SMTP server calls, then it will not be of much use to me.

Sriram.
0
 
LVL 12

Expert Comment

by:roverm
ID: 6903269
I will check to which library it belongs, but thought it was the standard CDONTS dll.

It doesn't use direct SMTP calls because it connects to your exchange server.

D'Mzzl!
RoverM
0
 
LVL 1

Expert Comment

by:kodiakbear
ID: 7666202
Moving to the Paq

kb
Experts Exchange Moderator
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now