Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Outlook question

Posted on 2001-08-31
8
Medium Priority
?
280 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:anthony_glenwright
ID: 6445542
Sorry, didn't mean to post that as an answer...
0
 

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 400 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…
Suggested Courses

636 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