Solved

Outlook question

Posted on 2001-08-31
8
267 Views
Last Modified: 2012-08-14
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
 
0
Comment
Question by:rian
8 Comments
 
LVL 6

Expert Comment

by:anthony_glenwright
ID: 6445442
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
 

Author Comment

by:rian
ID: 6445453
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
 
LVL 6

Expert Comment

by:anthony_glenwright
ID: 6445537
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
 
LVL 6

Expert Comment

by:anthony_glenwright
ID: 6445542
Sorry, didn't mean to post that as an answer...
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Expert Comment

by:ComTech
ID: 6445601
anthony_glenwright, has asked us to reject the comment.  Thought I believe his comment still shoud be considered.

Thanks all,
ComTech
Community Support
0
 

Author Comment

by:rian
ID: 6445902
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
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 100 total points
ID: 6445904
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
 
LVL 6

Expert Comment

by:anthony_glenwright
ID: 6446982
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

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

708 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

18 Experts available now in Live!

Get 1:1 Help Now