Outlook question

I am having an problem with Outlook 98. I am creating in VB an email message with an attachment. However I do not fill the SenderName property. I do'nt know how to since it is a read only property. I get an error from outlook which says something like "someone is trying to send an email. Could be a virus. are you sure"


I wanted to find out how I can fill the sendername value even if Outlook is not open and also do a name resolution in Outlook.

Appreciate all the help

Here is a sample code
I am using the Outlook 98 object reference

Dim objOutlook As New Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
 
If Len(txtemail) > 0 Then
    'Create a message.
    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
    objOutlookMsg.Display
    With objOutlookMsg
        .To = txtemail.Text
        .Subject = "Request for Quotation"
        .Body = "Dear " & txtAttention & vbNewLine & vbNewLine
        .Body = .Body & "Please quote price and delivery for the following parts" & vbNewLine
        .Body = .Body & "in the attached EXCEL spreadsheet and return" & vbNewLine
        .Body = .Body & " THANK YOU" & vbNewLine
        .Importance = olImportanceHigh
        .Attachments.Add (savestr)
        .Send
    End With
End If
 
Set objOutlook = Nothing
 
rianAsked:
Who is Participating?
 
Anthony PerkinsConnect With a Mentor Commented:
Take a look at this article

Hitting the Outlook Security Brick Wall

...or How I Wasted Hours Trying to E-mail 1,900 Invitations

http://www.devx.com/free/newsletters/exo/exoed062201.asp
0
 
anthony_glenwrightCommented:
It looks like you've run into Outlook's anti-macro virus "protection".  Perhaps you would have better luck using CDO to send the mail.  

In Windows 2000 (the CDO object model is differnt in WinNT/Win9x), the code is something like:

  set objCDOMain = CreateObject ("CDO.Message")
 
  ' configure the SMTP mail options
  objCDOMain.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  objCDOMain.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "yoursmtpserver.com
  objCDOMain.Configuration.Fields.Update
 
  ' configure the actual message
  objCDOMain.From = "'my name' <myname@mydomain.com>
  objCDOMain.To = "'someone else' <someone@somedomain.com>"
  objCDOMain.Subject = "my message title"  
  objCDOMain.TextBody = "this is my message!"
 
  ' send the message
  objCDOMain.Send
0
 
rianAuthor Commented:
I am not sure if you can use CDO on windows 95/98. What is the reference object. Can I use the same code in windows95/98/nt
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
anthony_glenwrightCommented:
You would have to use different code in Win2k from win9x and Winnt... you would have to use GetVersionEx() to determine what O.S. was running...

But I think you will be best off using CDO, because it sounds like you have the Outlook patch that protects against macro viruses (and legitimate applications too, unfortuneately).

CDO ships with Win2k, so you dont have to install anything special there.  For Win 9x and NT, CDO is installed with Outlook 98.  Microsoft do not provide CDO with a redistributable license, so installing Outlook (and Exchange, I think) is the only way to get it.

The reference you use for Win9x/NT is "Microsoft CDO 1.21 Library".  The reference for Win2k is "Microsoft CDO for Windows 2000 Library".

If you want to support a range of operating systems, dont bother including the reference - just declare your object variable .. As Object and use CreateObject.

i.e.

Dim objCDOMain as object

set objCDOMain = CreateObject ("CDO.Message")

If OS=Win2k then
  ' use the win2k example from above
else
  ' use the win9x, etc code from http://support.microsoft.com/support/kb/articles/Q161/8/33.asp
end if
0
 
anthony_glenwrightCommented:
Sorry, didn't mean to post that as an answer...
0
 
ComTechCommented:
anthony_glenwright, has asked us to reject the comment.  Thought I believe his comment still shoud be considered.

Thanks all,
ComTech
Community Support
0
 
rianAuthor Commented:
I am not sure if you can use CDO on windows 95/98. What is the reference object. Can I use the same code in windows95/98/nt
0
 
anthony_glenwrightCommented:
You may be right - it may not work in Win9x - I don't know.  But it will only take a minute to try the code from:
  http://support.microsoft.com/support/kb/articles/Q161/8/33.asp

... to find out.  (I don't have a Win9x machine to try).
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.